Skip to content

postgresql_cdc: support re-snapshotting a table if already snapshotted - #5145

Merged
josephwoodward merged 4 commits into
mainfrom
jw/postgres_cdc_restart_inc_snapshot
Nov 5, 2026
Merged

josephwoodward merged 4 commits into
mainfrom
jw/postgres_cdc_restart_inc_snapshot

Conversation

@josephwoodward

@josephwoodward josephwoodward commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This change allows users to resignal an incremental snapshot of a table once it's completed.

It also tidies up the Taskfile to align it with the way the Oracle connector works by introducing a common set of commands:

bench:up
bench:down
bench:run

Proof of Work

  1. Demonstrates the snapshot of table cart, followed by a snapshot being discarded because it's currently in progress
  2. Re-shapshot of cart table one initial snapshot in .1 completed

Total count is 1000003 (2x cart table snapshots of 500,000, 3x snapshot-execute)

image

@josephwoodward
josephwoodward marked this pull request as ready for review November 4, 2026 13:37
@josephwoodward
josephwoodward force-pushed the jw/postgres_cdc_restart_inc_snapshot branch from b985c9e to f45933f Compare November 4, 2026 13:38
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Connect docs check

The docs build passed with this PR's generated docs.

Preview: https://connect-pr-5145--redpanda-connect.netlify.app/connect/home/

This PR changes 2 published pages (2 generated files: 2 changed, 0 added, 0 removed). Review the rendered pages, not only the Go strings.

Page Preview
/connect/components/inputs/pg_stream/ preview
/connect/components/inputs/postgres_cdc/ preview

Per-file diffs and the rendered-HTML findings are in the job summary. Checked at f749431.

@vbotbuildovich
vbotbuildovich requested a review from a team November 4, 2026 13:51
@josephwoodward
josephwoodward force-pushed the jw/postgres_cdc_restart_inc_snapshot branch from f45933f to 03962a1 Compare November 4, 2026 15:18
@josephwoodward
josephwoodward force-pushed the jw/postgres_cdc_restart_inc_snapshot branch from a86f980 to 0e1021b Compare November 4, 2026 15:34
@josephwoodward
josephwoodward force-pushed the jw/postgres_cdc_restart_inc_snapshot branch from 0e1021b to bc165c6 Compare November 4, 2026 16:02
}

added := s.incSnapshot.coordinator.AddTables(tables)
added := s.incSnapshot.coordinator.RequeueTables(tables)

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.

Re-snapshotting a table makes postgres_snapshot_progress read above 100%. Zero the counter when a table starts (ResetSnapshotProgress in the current != nil branch of reportTableTransition).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I've reset them on receiving of the snapshot signal 64153fd


// flights is now FINISHED in the checkpoint the next run loads, so this
// signal must re-queue it and deliver the whole table again.
thirdRun := runPartial(numRows, false)

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.

Third run only covers restart re-signalling; the same-run case (idle coordinator, table in knownTables) is untested and is where the metric reset shows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added a new test here to capture snapshotting the re-snapshotting the same table in the same process. fdef796

@josephwoodward
josephwoodward force-pushed the jw/postgres_cdc_restart_inc_snapshot branch from f749431 to f867785 Compare November 5, 2026 02:12
waitForPass(2)

got, n := readCounts()
assert.Equal(t, 2*numRows, n, "expected each pass to read the table exactly once")

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.

This test proves the second signal re-reads the table, but nothing checks that dispatchSnapshotSignal actually calls ResetSnapshotTable. If that call were dropped, TestMonitorResnapshotProgress and this test would both still pass, and postgres_snapshot_progress would read 2.0 again. Two cheap ways to close that: register a metrics exporter here and assert the flights gauge is <= 1 after the second pass, or add a unit test in incremental_snapshot_test.go that builds a Stream with monitor: newTestMonitor(...), marks a table complete, dispatches a signal for it, and asserts m.Report().TableProgress no longer has the table. Fine as a follow-up.

@josephwoodward
josephwoodward merged commit 9da07d3 into main Nov 5, 2026
14 of 15 checks passed
@josephwoodward
josephwoodward deleted the jw/postgres_cdc_restart_inc_snapshot branch November 5, 2026 22:30
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.

2 participants