Skip to content

Adds drain support to Spanner CDC source. - #39994

Closed
acrites wants to merge 2 commits into
apache:masterfrom
acrites:spanner-cdc-drain
Closed

acrites wants to merge 2 commits into
apache:masterfrom
acrites:spanner-cdc-drain

Conversation

@acrites

@acrites acrites commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Before this change, we were calling the default implementation of truncateRestriction on drain, which, for bounded restrictions tries to finish evaluating the entire restriction. Both SDF's in the Spanner CDC source use bounded restrictions that are effectively unbounded. Overriding truncateRestriction to return null on these SDFs allows terminating immediately.

In addition, we had to change the cleanup action from DROP TABLE to DROP TABLE IF EXISTS to make deletion idempotent. Otherwise, if that work item gets retried by the backend, it will start fail-looping, preventing drain from completing.

We don't have a great way to test drain here, but I ran a test pipeline on Dataflow and verified that it can now drain successfully.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…ion on SDFs allows terminating immediately and changing to DROP TABLE IF EXISTS makes deletion idempotent.
@github-actions

github-actions Bot commented Sep 3, 2026

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

@acrites

acrites commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

The remaining failing PreCommit Spotless check says it's failing at :sdks:java:io:iceberg:checkstyleMain, but when I run that locally it passes.

@stankiewicz

stankiewicz commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

2026-09-04T08:36:38.6399796Z [ant:checkstyle] [ERROR] /runner/_work/beam/beam/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/cdc/sink/CdcRecord.java:20: You are using raw guava, please use vendored guava classes. [ForbidNonVendoredGuava]

#40015 forward fix under way

@acrites

acrites commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Run Spotless PreCommit

@acrites

acrites commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

assign set of reviewers

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn for label java.
R: @nielm for label spanner.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @Abacn @nielm

@acrites

acrites commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

I would still like to get some feedback from the Spanner team on what the best drain behavior should be. This PR makes drain possible, but it makes it hard to resume from drain since the metadata table gets deleted. Is that ok for v1? A better solution would keep the metadata tables intact and then upon resuming we would scan these tables to somehow pick up where we left off.

If we want to wait until we implement a resumable drain that's fine and I can just get rid of this PR.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @ahmedabu98 for label java.
R: @nielm for label spanner.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @ahmedabu98 @nielm

@github-actions

Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @kennknowles for label java.
R: @nielm for label spanner.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

@kennknowles kennknowles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems fine to me, I guess! It is your PR description that gave me pause - why are there unbounded restrictions that are essentially unbounded? That's a discussion we don't have to have here (and not particularly something I need to get nosy about... 😄 )

@kennknowles

Copy link
Copy Markdown
Member

waiting on author

@acrites

acrites commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Let's go ahead and hold of on this implementation. I'll try to come up with something that would allow us to "resume" a drained pipeline by pointing it to the same metadata table.

@jiangzzhu

Copy link
Copy Markdown
Contributor

cc: @jiangzzhu

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.

4 participants