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
Contributor

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
@rohityan
Copy link
Copy Markdown
Collaborator

rohityan commented Apr 9, 2026

/gemini review

@rohityan
Copy link
Copy Markdown
Collaborator

Hi @enjoykumawat , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan
Copy link
Copy Markdown
Collaborator

Hi @wukath , can you please review this

@rohityan rohityan added the needs review [Status] The PR/issue is awaiting review from the maintainer label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review [Status] The PR/issue is awaiting review from the maintainer 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