Skip to content

fix(spanner): dispatch PG SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS correctly - #15282

Merged
sakthivelmanii merged 1 commit into
mainfrom
fix-pg-exclude-txn-from-change-streams
Dec 1, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
fix-pg-exclude-txn-from-change-streams

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem Statement

  • On PostgreSQL-dialect Cloud Spanner connections, executing SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS = true (or TO true) did not exclude subsequent transactions from change streams and instead toggled SPANNER.RETURN_COMMIT_STATS.
  • As a result, transactions explicitly marked to be excluded from change streams were still emitted to change streams, while commit statistics were unexpectedly enabled.

Solution

  • Route PostgreSQL SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS statements to the change-stream exclusion setting instead of the commit-stats setting.
  • Executing SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS after a transaction has started or while a batch is active now fails with FAILED_PRECONDITION instead of silently mutating SPANNER.RETURN_COMMIT_STATS, matching GoogleSQL behavior.

… correctly

## Problem Statement
- On PostgreSQL-dialect Cloud Spanner connections, executing `SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS = true` (or `TO true`) did not exclude subsequent transactions from change streams and instead toggled `SPANNER.RETURN_COMMIT_STATS`.
- As a result, transactions explicitly marked to be excluded from change streams were still emitted to change streams, while commit statistics were unexpectedly enabled.

## Solution
- Route PostgreSQL `SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS` statements to the change-stream exclusion setting instead of the commit-stats setting.
- Executing `SET SPANNER.EXCLUDE_TXN_FROM_CHANGE_STREAMS` after a transaction has started or while a batch is active now fails with `FAILED_PRECONDITION` instead of silently mutating `SPANNER.RETURN_COMMIT_STATS`, matching GoogleSQL behavior.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 30, 2026 08:26

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

Copy link
Copy Markdown
Contributor

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 corrects the client-side statement method mapping for SET_EXCLUDE_TXN_FROM_CHANGE_STREAMS in PostgreSQL and expands test coverage by parameterizing ExcludeTxnFromChangeStreamsMockServerTest across all dialects. However, the parameterized test setup contains a critical issue: the @Parameters method returns a 1D array of Dialect values instead of a 2D array or an Iterable of arrays, which will lead to a ClassCastException during JUnit 4 test initialization.

@sakthivelmanii
sakthivelmanii merged commit df54279 into main Dec 1, 2026
197 checks passed
@sakthivelmanii
sakthivelmanii deleted the fix-pg-exclude-txn-from-change-streams branch December 1, 2026 16:20
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