ptrdom opened a new pull request, #534: URL: https://github.com/apache/pekko-persistence-r2dbc/pull/534
### Motivation MariaDB is a widely used open source database that was not supported. It is close to MySQL, but differs in the snapshot upsert syntax, and its R2DBC driver (`org.mariadb:r2dbc-mariadb`, Apache License 2.0) has no `java.time.Instant` support. ### Modification - Add the `mariadb` dialect. It reuses the MySQL journal, query and durable state DAOs and the MySQL DDL, and upserts snapshots with `VALUES(col)`, as MariaDB doesn't support the `AS excluded` row alias of MySQL. Like MySQL, it requires `use-app-timestamp` and `db-timestamp-monotonic-increasing`: MariaDB supports `INSERT ... RETURNING`, but `NOW()` is the start time of the statement, not of the transaction. - Add an internal `ConnectionAdapter`, which wraps the connections of a driver and converts bound and read values. For the MariaDB driver, `Instant` is bound and read as UTC `LocalDateTime`, and the `timezone` option of the driver is set to `UTC` so that the session time zone matches. A UTC session is used rather than the server time zone, as local times are ambiguous when daylight saving time ends. The adapter is adapted from the `OracleConnections` of the in-progress Oracle dialect, so that both can share it. - Add a `test-mariadb` CI job and `docker/docker-compose-mariadb.yml`, and document the dialect. - Second commit: add `DbTimestampDstSpec`, which stores and reads events with timestamps before and after the next fall-back transition of `America/New_York`, and checks the instants stored by MySQL and MariaDB servers. It fails if the zone doesn't observe daylight saving time anymore, or if the database server doesn't run in that zone. The MariaDB container runs in `America/New_York`. The spec is pending for MySQL until #533 is fixed. ### Result MariaDB 10.11 or later can be used with the `mariadb` dialect and the `r2dbc-mariadb` driver, and CI verifies timestamps around daylight saving time changes. ### Tests - `sbt -Dpekko.persistence.r2dbc.dialect=mariadb test` (MariaDB 12.3.3 in `America/New_York`) - 319 passed - `sbt -Dpekko.persistence.r2dbc.dialect=mariadb core/test` (MariaDB 10.11.19) - 316 passed, `MariaDBTimeZoneSpec` assertion fixed for a UTC server and re-run - passed - `MariaDBTimeZoneSpec` fails without the `timezone` option of the driver - `sbt -Dpekko.persistence.r2dbc.dialect=mysql core/test` (MySQL 9.5.0) - 309 passed - `sbt -Dpekko.persistence.r2dbc.dialect=h2 core/test` - 316 passed - `R2dbcSettingsSpec`, which failed in the MySQL and H2 runs above, fixed and re-run with the h2, mysql, mariadb and postgres dialects - passed - `sbt core/test` (PostgreSQL) - 396 passed - `DbTimestampDstSpec`: passes with mariadb, postgres and h2; fails with mysql when not pending (stored instants shifted by 7 hours), and with a MariaDB server in UTC (server must run in `America/New_York`) - `sbt +Test/compile +mimaReportBinaryIssues +headerCheckAll docs/paradox` - success - `scalafmt`, `sbt javafmtAll` (JDK 17), `git diff --check` - clean ### References Refs #94, Refs #533 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
