ptrdom opened a new pull request, #537:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/537

   ### Motivation
   The MySQL driver was configured with `connectionTimeZone = SERVER`, so 
`Instant` values were converted with the server time zone. Timestamps in the 
local hour that repeats when daylight saving time ends were stored and read 
shifted by one hour. When the driver can't resolve the server zone (e.g. 
`@@system_time_zone = EDT`), it falls back to the JVM zone, and all timestamps 
are stored shifted by the offset between the JVM and server zones. Round trips 
through the plugin hid this because both directions apply the same wrong 
conversion.
   
   ### Modification
   - Set `connectionTimeZone = UTC` and `forceConnectionTimeZoneToSession = 
true` for the MySQL driver.
   - Run the MySQL container in `America/New_York`, as the MariaDB one already 
is.
   - Generalize `MariaDBTimeZoneSpec` to `DbTimeZoneSpec`, which runs for MySQL 
and MariaDB and checks the UTC session time zone, the stored value of a bound 
`Instant`, and reading `NOW(6)`.
   - Enable `DbTimestampDstSpec` for MySQL.
   - Document that MySQL sessions use UTC, so SQL run on the plugin's 
connections (e.g. in a `ChangeHandler`) sees `NOW()` in UTC.
   
   ### Result
   MySQL sessions use UTC, and timestamps are stored and read as the same 
instants whatever the server time zone is.
   
   ### Tests
   - `DbTimeZoneSpec` and `DbTimestampDstSpec` with database servers in 
`TZ=America/New_York` and the JVM in another zone:
     - MySQL 9.5.0 (`@@system_time_zone = EDT`): before the fix 4 failed, 1 
passed; after the fix 5 passed
     - MariaDB 12.3.3: 5 passed
   - `sbt -Dpekko.persistence.r2dbc.dialect=mysql test`: 328 succeeded, 0 
failed, 98 pending
   - Postgres, Yugabyte, H2: not run locally, the changed specs are pending for 
them
   - `scalafmt`, `git diff --check`: clean
   
   ### References
   Fixes #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]

Reply via email to