Skip to content

test(e2e): fix the flaky parallel WAL restore spec on slow runners - #1262

Merged
mnencia merged 3 commits into
mainfrom
fix/e2e-walrestore-streaming-retry
Nov 27, 2026
Merged

mnencia merged 3 commits into
mainfrom
fix/e2e-walrestore-streaming-retry

Conversation

@leonardoce

@leonardoce leonardoce commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The "Parallel WAL restore" spec runs /controller/manager wal-restore by hand on a standby, and sometimes failed with exit code 1 on the first request (WAL #1) or on the first one after the spool is drained (WAL #4).

The cause is a CloudNativePG feature. To let PostgreSQL retry streaming replication, the instance manager makes wal-restore fail on purpose for 5s every 30s on a standby, for any segment that is not in the spool. On a fast runner the spec finishes before the first window opens. On a standard ubuntu-latest runner, such as the ones used by pull requests from forks, cluster creation and WAL forging are slow enough for the window to open first.

Replace the state file the instance manager keeps (/controller/wal-restore-streaming-retry.json) with an empty read-only one. The instance manager cannot store its state, so it never fails a restore on purpose, however slow the runner is.

Also make failures diagnosable. ExecuteInContainer now returns stdout and stderr on a non-zero exit. A failing wal-restore prints them with the tail of the plugin sidecar logs, and a failing WAL forge includes the aws CLI stderr.

Assisted-by: Claude

@leonardoce
leonardoce requested a review from a team as a code owner November 26, 2026 14:26
The "Parallel WAL restore" spec invokes `/controller/manager wal-restore`
by hand on a standby, and sometimes failed with exit code 1 on the first
request (WAL #1) or on the first one after the spool is drained (WAL #4).

The cause is a CloudNativePG feature: to let PostgreSQL retry streaming
replication, the instance manager makes wal-restore fail on purpose for
5s every 30s on a standby, for any segment that is not already in the
spool ("Failing restore_command on purpose to let streaming replication
resume"). The 30s are measured from the first restore of the standby,
which is recorded in /controller/wal-restore-streaming-retry.json.

On a fast runner the spec sends its requests before the first window
opens. On a standard `ubuntu-latest` runner, such as the ones used by
pull requests from forks, cluster creation and the WAL forging take long
enough for the window to open first, and the request is rejected.

Remove the state file right before the first request, so the whole
sequence runs inside a fresh window.

Also make failures diagnosable: ExecuteInContainer used to drop stdout
and stderr on a non-zero exit, so the failure only showed the exit code.
It now returns them along with the error, and a failing wal-restore
prints its output together with the tail of the plugin sidecar logs.
The aws CLI stderr is included when forging a WAL segment fails.

Assisted-By: Claude

Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Removing the state file starts a new 30s interval at the first restore
after it, the request for WAL #1, but the instance manager still checks
every request whose segment is not in the spool: #4, both requests for
#6 and the child-timeline one. If the sequence takes longer than 30s,
one of them can still be failed on purpose.

Replace the state file with an empty read-only one instead. The
instance manager cannot store its state and then never fails a restore
on purpose, so the forced failures stay off for the whole spec,
whatever the speed of the runner.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
@mnencia
mnencia merged commit 2cc6b90 into main Nov 27, 2026
10 checks passed
@mnencia
mnencia deleted the fix/e2e-walrestore-streaming-retry branch November 27, 2026 16:50
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.

3 participants