Skip to content

Fix BigtableIO RESUME_OR_NEW duplicate InitializeDoFn execution - #40107

Open
arimu1 wants to merge 2 commits into
apache:masterfrom
arimu1:fix/39970-bigtable-resume-or-new
Open

arimu1 wants to merge 2 commits into
apache:masterfrom
arimu1:fix/39970-bigtable-resume-or-new

Conversation

@arimu1

@arimu1 arimu1 commented Sep 13, 2026

Copy link
Copy Markdown

Summary

  • When BigtableIO.readChangeStream() uses ExistingPipelineOptions.RESUME_OR_NEW, a re-executed InitializeDoFn (e.g. Dataflow bundle retry) could see Detect New Partition metadata written by the same job and take the resume path, emitting a second InitialPipelineState and starting duplicate change-stream consumers.
  • Assign a stable per-pipeline-run id at graph construction time, persist it in the metadata table on successful initialization, and skip InitializeDoFn output when the stored id matches the current run. A genuinely new job still resumes when the stored id differs.

Fixes #39970

Test plan

  • Added InitializeDoFnTest.testInitializeSkipsDuplicatePipelineRun (emulator)
  • ./gradlew :sdks:java:io:google-cloud-platform:test --tests org.apache.beam.sdk.io.gcp.bigtable.changestreams.dofn.InitializeDoFnTest (local run hit disk pressure on cold clone; CI expected to run)

Record a per-pipeline run id during InitializeDoFn and skip re-execution when the metadata already belongs to the same run, so RESUME_OR_NEW cannot start a second consumer chain inside one job.

Fixes apache#39970
Use a unique change stream name per test and mark prior-job metadata in the resume case so shared emulator rows do not skip initialization.
@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BigtableIO.readChangeStream() with RESUME_OR_NEW can start duplicate consumers inside one Dataflow job

1 participant