Skip to content

Fix CDC endpos on an idle source, retry COPY on source loss, move to Debian 12 - #60

Merged
teknogeek0 merged 4 commits into
mainfrom
fix/cdc-endpos-and-copy-reconnect
Sep 14, 2026
Merged

teknogeek0 merged 4 commits into
mainfrom
fix/cdc-endpos-and-copy-reconnect

Conversation

@teknogeek0

Copy link
Copy Markdown
Collaborator

Four independent fixes found while running a live migration from a read replica.

Stop CDC when the endpos is set on an idle source. The feedback-timer guard in pgsql_stream_logical tested cur_record_lsn, which is declared inside the streaming loop and reset to InvalidXLogRecPtr on every iteration, so the test never passed. It now tests the position already streamed. Without this, setting the sentinel endpos on a source with no further WAL activity never stops the stream, and a replica source cannot be nudged with a write.

Retry table COPY after a source connection failure. Treats 57P01, 57P02 and 57P03 as connection errors and resets both connections between attempts, re-opening the snapshot when the source is the snapshot connection. Adds the copy-source-reconnect suite.

Skip smoke tests on fork pull requests. Runs them on pushes and same-repo pull requests only.

Move the base image to Debian 12. Debian 11 is on LTS and its security archive no longer serves the package versions its index advertises, so apt-get install fails with a 404 on the pgcopydb image. This broke the eight suites that build a Dockerfile.inject on that image. tests/Dockerfile.pagila was already on bookworm. This changes the published image. The same commit passes PGCOPYDB_IMAGE to the exclude-extension test service, which hardcoded pgcopydb:pg16 and so failed the PG17 and PG18 cells.

Tests

Full suite green at PGVERSION=18, all 34 suites. citus_indent --check passes.

The run needs Docker network pruning partway through: the default address pool holds about 30 networks and the suites leave one behind each, which is a local limit, not a CI one.

Known gap, not addressed here

About eleven suites build their source database from a Dockerfile.pg whose ARG PGVERSION=16 default is never overridden, because their compose.yaml passes no build args. The target follows the matrix, the source does not, so the PG18 cell of cdc-wal2json runs a PG16 source into a PG18 target. Pre-existing, and left alone because fixing it may surface real PG18 failures that deserve their own triage.

Treat 57P01, 57P02 and 57P03 as connection errors, and reset both the
source and target connections between COPY attempts. When the source is
the snapshot connection, re-open the snapshot as well. Skip the COMMIT at
snapshot close when the connection is already gone.

Adds the copy-source-reconnect test suite.
The feedback-timer guard tested cur_record_lsn, which is declared inside
the streaming loop and reset to InvalidXLogRecPtr on every iteration, so
the test never passed. Test the position already streamed instead.

Without this, setting the sentinel endpos on a source with no further WAL
activity never stops the stream. A replica source cannot be nudged with a
write, so the follow process runs forever.
Run them on pushes and same-repo pull requests only. Also register the
copy-source-reconnect suite in the tiered test matrix.
Debian 11 is on LTS and its security archive no longer serves the package
versions its index advertises, so apt-get install fails with a 404 on the
pgcopydb image. This broke the eight test suites that build a
Dockerfile.inject on that image. tests/Dockerfile.pagila already uses
bookworm.

Also pass PGCOPYDB_IMAGE to the exclude-extension test service, which
hardcoded pgcopydb:pg16 and so failed the PG17 and PG18 matrix cells.
@teknogeek0
teknogeek0 merged commit 57d82a0 into main Sep 14, 2026
108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants