Skip to content

fix: strip timezone from datetime for MySQL to prevent stale-writer false positive#5209

Open
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
enjoykumawat:fix/mysql-datetime-timezone-strip
Open

fix: strip timezone from datetime for MySQL to prevent stale-writer false positive#5209
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
enjoykumawat:fix/mysql-datetime-timezone-strip

Conversation

@enjoykumawat
Copy link
Copy Markdown

Summary

  • Add MySQL to the timezone stripping check in create_session() alongside SQLite and PostgreSQL
  • MySQL DATETIME(fsp=6) silently drops timezone info, causing _storage_update_marker mismatch on first append_event()

Root Cause

create_session() creates a tz-aware datetime (tz=timezone.utc) and derives the _storage_update_marker from it (includes +00:00). MySQL DATETIME drops timezone on storage. When append_event() reads update_time back, it gets a naive datetime, produces a different marker string, and the strict comparison fails with ValueError: The session has been modified in storage since it was loaded.

The code already handled this for SQLite and PostgreSQL (line 464) but MySQL was missing.

Test Plan

  • Updated parametrized test to include MySQL in timezone stripping
  • Updated "preserves timezone" test to use Spanner instead of MySQL
  • All session service tests pass

Fixes #5085

…alse positive

MySQL DATETIME(fsp=6) silently drops timezone info on storage, so a
tz-aware datetime written by create_session produces a different
_storage_update_marker string than the naive datetime read back by
append_event, causing a false ValueError on the first append after
create.

The code already handled this for SQLite and PostgreSQL but not MySQL.
Add MySQL to the timezone stripping check.

Fixes google#5085
@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Apr 8, 2026
@rohityan rohityan self-assigned this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL: stale-writer false positive on first append_event after create_session

3 participants