Visitar URL original
fix: fix flaky CopyBothResponseTest by using WAL flush LSN by vlsi · Pull Request #3979 · pgjdbc/pgjdbc · GitHub
Skip to content

fix: fix flaky CopyBothResponseTest by using WAL flush LSN - #3979

Merged
vlsi merged 1 commit into
pgjdbc:masterfrom
vlsi:fix/flaky-CopyBothResponseTest-wal-flush
Mar 20, 2026
Merged

vlsi merged 1 commit into
pgjdbc:masterfrom
vlsi:fix/flaky-CopyBothResponseTest-wal-flush

Conversation

@vlsi

@vlsi vlsi commented Mar 20, 2026

Copy link
Copy Markdown
Member

Similar to 2a7ac41 which fixed flaky replication restart tests in LogicalReplicationTest by waiting for confirmed_flush_lsn.

It should fix failure like

https://github.com/pgjdbc/pgjdbc/actions/runs/23354694589/job/67942890085?pr=3844

FAILURE   0,2sec, org.postgresql.replication.CopyBothResponseTest > receiveXLogData()
    org.postgresql.util.PSQLException: ERROR: requested starting point 0/B626000 is ahead of the WAL flush position of this server 0/B622000
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2895)
        at org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:1434)
        at org.postgresql.core.v3.QueryExecutorImpl.readFromCopy(QueryExecutorImpl.java:1330)
        at org.postgresql.core.v3.CopyDualImpl.readFromCopy(CopyDualImpl.java:49)
        at org.postgresql.core.v3.CopyDualImpl.readFromCopy(CopyDualImpl.java:43)
        at org.postgresql.replication.CopyBothResponseTest.receiveXLogData(CopyBothResponseTest.java:144)

Use pg_current_wal_flush_lsn() instead of pg_current_wal_lsn() in
CopyBothResponseTest.getCurrentLSN(). The test uses physical replication
(START_REPLICATION without a slot), which requires the starting point
to be at or before the WAL flush position. pg_current_wal_lsn() returns
the write position, which can be ahead of the flush position under
concurrent WAL activity, causing the error:
"requested starting point is ahead of the WAL flush position of this server"

Also relax the keep-alive LSN assertion in keedAliveContainsCorrectLSN()
to use greaterThanOrEqualTo instead of equalTo, since the keep-alive
reports end-of-WAL (write position) which can be ahead of the flush LSN.

Similar to 2a7ac41 which fixed flaky replication restart tests in
LogicalReplicationTest by waiting for confirmed_flush_lsn.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vlsi
vlsi merged commit 1c586bb into pgjdbc:master Mar 20, 2026
16 checks passed
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.

1 participant