Repository navigation
[SpannerIO] Support excludeTxnFromChangeStreams and transactionTag in SpannerIO.Write - #40489
Merged
Merged
Conversation
Contributor
|
Assigning reviewers: R: @ahmedabu98 for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
darshan-sj
force-pushed
the
excludeFromChangeStream
branch
from
October 15, 2026 05:52
557d598 to
98106e2
Compare
damccorm
approved these changes
Oct 15, 2026
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.
Currently,
SpannerIO.Write(WriteToSpannerFn.getTransactionOptions()) only forwardsOptions.priority(...)andOptions.maxCommitDelay(...)when callingDatabaseClient.writeAtLeastOnceWithOptions(batch, getTransactionOptions()). It does not expose a way for callers to set:Options.excludeTxnFromChangeStreams()— to exclude write transactions from being recorded in Cloud Spanner change streams configured with the DDL optionallow_txn_exclusion = true(e.g., during bulk backfills or forward database migrations so reverse replication pipelines do not re-process migrated writes).Options.tag(String)— to attach a transaction tag (RequestOptions.transaction_tag) to write transactions for Spanner transaction statistics (SPANNER_SYS.TXN_STATS*) and downstream change stream filtering.Changes
SpannerConfig:getExcludeTxnFromChangeStreams()andwithExcludeTxnFromChangeStreams(boolean)/withExcludeTxnFromChangeStreams(ValueProvider<Boolean>).getTransactionTag()andwithTransactionTag(String)/withTransactionTag(ValueProvider<String>).SpannerIO.Write&WriteToSpannerFn:withExcludeTxnFromChangeStreams(...)andwithTransactionTag(...)builder methods onSpannerIO.Write.WriteToSpannerFn.getTransactionOptions()to includeOptions.excludeTxnFromChangeStreams()whenexcludeTxnFromChangeStreamsistrue, andOptions.tag(...)whentransactionTagis non-empty.Tests:
Extended
OptionsImposterwithwithExcludeTxnFromChangeStreams(Options)andtag(Options).Added
runBatchQueryTestWithExcludeTxnFromChangeStreamsandrunBatchQueryTestWithTransactionTaginSpannerIOWriteTest.End-to-End Dataflow Pipeline Verification:
beam-sdks-java-io-google-cloud-platformartifact in theSourcedb_to_Spanner_FlexDataflow template and migrated a MySQL table into a Cloud Spanner database configured withCREATE CHANGE STREAM change_stream FOR ALL OPTIONS (allow_txn_exclusion = true).SPANNER_SYS.TXN_STATS_TOP_MINUTEthat all write transactions carried the configured transaction tag (txBy=bulk-<jobId>).READ_change_streamacross all change stream partitions that0data_change_records were emitted during the migration.Checklist
./gradlew :sdks:java:io:google-cloud-platform:spotlessApply)./gradlew :sdks:java:io:google-cloud-platform:test --tests org.apache.beam.sdk.io.gcp.spanner.SpannerIOWriteTest)