fix: strip tzinfo from datetime for MySQL in create_session#5084
Open
andreikravchenko-oviva wants to merge 1 commit intogoogle:mainfrom
Open
fix: strip tzinfo from datetime for MySQL in create_session#5084andreikravchenko-oviva wants to merge 1 commit intogoogle:mainfrom
andreikravchenko-oviva wants to merge 1 commit intogoogle:mainfrom
Conversation
MySQL DATETIME(fsp=6) does not store timezone information, same as SQLite and PostgreSQL. However, create_session only stripped tzinfo for SQLite and PostgreSQL, leaving it intact for MySQL. This caused a stale-writer false positive on the first append_event after create_session: the storage_update_marker from create_session included "+00:00" (timezone-aware), but get_session reads back a naive datetime from MySQL, producing a marker without "+00:00". The strict string comparison in append_event then raised ValueError. Add MySQL to the dialect check that strips tzinfo before storing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
Fixes #5085
When using
DatabaseSessionServicewith MySQL, the very firstappend_event()aftercreate_session()always fails with:Root cause:
create_session()produces a timezone-aware_storage_update_marker(with+00:00), but MySQLDATETIME(fsp=6)doesn't store timezone info (MySQL docs). Whenappend_event()readsupdate_timeback, it gets a naive datetime — different marker string, strict comparison fails.The code already strips
tzinfofor SQLite and PostgreSQL but MySQL was missed:Testing Plan
Unit Tests:
Added
mysqlto the existing parametrized dialect test. Removed the test that incorrectly asserted MySQL preserves timezone.Manual End-to-End (E2E) Tests:
Verified marker values with Testcontainers MySQL 8.0:
...T14:39:46.014977+00:00...T14:39:46.014977...T14:44:49.388273...T14:44:49.388273Confirmed that
append_event()works immediately aftercreate_session()without needing a re-fetch workaround.Checklist