Repository navigation
postgresql_cdc: support re-snapshotting a table if already snapshotted - #5145
Conversation
b985c9e to
f45933f
Compare
Connect docs checkThe docs build passed with this PR's generated docs. This PR changes 2 published pages (2 generated files: 2 changed, 0 added, 0 removed). Review the rendered pages, not only the Go strings.
Per-file diffs and the rendered-HTML findings are in the job summary. Checked at f749431. |
f45933f to
03962a1
Compare
a86f980 to
0e1021b
Compare
0e1021b to
bc165c6
Compare
| } | ||
|
|
||
| added := s.incSnapshot.coordinator.AddTables(tables) | ||
| added := s.incSnapshot.coordinator.RequeueTables(tables) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I've added a new test here to capture snapshotting the re-snapshotting the same table in the same process. fdef796
f749431 to
f867785
Compare
| waitForPass(2) | ||
|
|
||
| got, n := readCounts() | ||
| assert.Equal(t, 2*numRows, n, "expected each pass to read the table exactly once") |
There was a problem hiding this comment.
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.
This change allows users to resignal an incremental snapshot of a table once it's completed.
It also tidies up the
Taskfileto align it with the way the Oracle connector works by introducing a common set of commands:Proof of Work
cart, followed by a snapshot being discarded because it's currently in progresscarttable one initial snapshot in .1 completedTotal count is 1000003 (2x cart table snapshots of 500,000, 3x
snapshot-execute)