use quarkus managed datasources and multi-datasource support at runtime#153
use quarkus managed datasources and multi-datasource support at runtime#153barreiro wants to merge 9 commits into
Conversation
|
One suggestion regarding the @Id
@GeneratedValue
@org.hibernate.annotations.NativeGenerator
public Long id;This tells Hibernate to use the dialect-native strategy:
I tested locally — 342 tests pass on both PostgreSQL and SQLite with With
|
|
thanks @stalep, well spotted !! I took your suggestion for |
93cef9d to
53a4d1a
Compare
willr3
left a comment
There was a problem hiding this comment.
Does this change result in a single cli jar (target/cli/h5m.jar) that can work with either sqlite or postgresql based on changing some command line parameter? I'm concerned about removing the DatasourceConfiguration.getPath as that is what allowed for environment variable control of the local sqlite database location using H5M_PATH. Why did we need to replace the DtasourceConfiguration?
The sqlite integration was working prior to this PR, what change is requiring the |
there is a problem with the sqlite integration: it was not relying on JTA transactions. when adding transactions there are deadlocks caused by increasing the sequences (hibernate does that in it's own tx) to avoid that deadloak, we change the id genation to identity that never spawn a new tx. this is something that we already discussed, because sequences can cause "holes" in the ids when the server is restarted the only exception is |
d3c8029 to
6d0c999
Compare
|
after rebasing to current main branch, some more changes were needed:
|
…ction / callInNewTransaction methods
…only since it can exhaust the default 3 retries for sqlite
Summary:
DatasourceConfigurationandDuckDbDatasourceConfigurationclasses thatmanually created Agroal connection pools. Datasource configuration is now handled entirely through
application.properties, enabling Quarkus's built-in multi-datasourcesupport and dev services (e.g. automatic PostgreSQL provisioning in dev/test).
DuckDbDatasourceConfiguration.PanacheEntitytoPanacheEntityBasewith explicit@Idand@GeneratedValue(strategy = IDENTITY), which is required for SQLite compatibility (SQLitedoes not support PostgreSQL-style sequences).
SqliteConnectionInitializer) using Agroal'sAgroalPoolInterceptorto set WAL mode, synchronous=normal, and busy_timeout pragmas on eachnew SQLite connection, replacing the old import.sql approach.
WorkService.RETRY_LIMITchanged from 0 to 3, with error logging downgraded from error to debug for transient failures.FolderService.upload()now retries up to 3 times onPessimisticLockException(SQLITE_BUSY). The CLI upload path alsocollects futures and waits for all processing to complete before exiting.
statement-batch-size,order-inserts,order-updates) — the codebase uses already usespersist(), so batching was never actually taking effect. WithGenerationType.IDENTITY, it forces Hibernate to flush each INSERT immediately to retrieve the generated ID.ci.ymlandpull-request.ymlnow run the test suite against PostgreSQL and SQLite in parallel using a build matrix (-DsqliteMaven profile).
FreshDb.dropRows()uses a single code path (DELETE statements) for both databases, with proper FK-safe ordering and transaction rollback handling. TheCliProfile now provides a fixed test DB path directly.