Skip to content

fix: cached session settings survived a rollback - #4872

Merged
olavloite merged 2 commits into
postgresql-dialectfrom
invalidate-session-settings-cache
Sep 29, 2026
Merged

olavloite merged 2 commits into
postgresql-dialectfrom
invalidate-session-settings-cache

Conversation

@olavloite

Copy link
Copy Markdown
Collaborator

The cached values for settings like TimeZone were only cleared by set(..), and not by commit() or rollback(). A SET inside a transaction that was rolled back therefore left the cached value in place, and it stayed wrong until the next SET happened to clear it.

Clear the cache on commit and rollback, but only when the transaction actually changed a setting. commit() runs for every statement in autocommit mode, so clearing it unconditionally would keep almost nothing in the cache.

The cached values for settings like TimeZone were only cleared by
set(..), and not by commit() or rollback(). A SET inside a transaction
that was rolled back therefore left the cached value in place, and it
stayed wrong until the next SET happened to clear it.

Clear the cache on commit and rollback, but only when the transaction
actually changed a setting. commit() runs for every statement in
autocommit mode, so clearing it unconditionally would keep almost
nothing in the cache.
@olavloite

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates SessionState to invalidate its cache during transaction commits and rollbacks when local or transaction settings are modified, preventing stale cached values. It also adds corresponding unit tests in SessionStateTest to verify this behavior. I have no feedback to provide as the implementation is correct and well-tested.

Comment thread src/test/java/com/google/cloud/spanner/pgadapter/session/SessionStateTest.java Outdated
@olavloite
olavloite merged commit 38ca0a7 into postgresql-dialect Sep 29, 2026
51 checks passed
@olavloite
olavloite deleted the invalidate-session-settings-cache branch September 29, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants