Skip to content

fix: make chaos tests meaningful; honor SIGTERM in background workers (PG14-18) - #34

Merged
valehdba merged 2 commits into
mainfrom
fix/chaos-tests
Nov 17, 2026
Merged

valehdba merged 2 commits into
mainfrom
fix/chaos-tests

Conversation

@valehdba

Copy link
Copy Markdown
Owner

Summary

  • test/test_chaos.sh: read worker/coordinator pids from pg_stat_activity (jobs_view has no worker_pid), kill with SIGTERM instead of SIGKILL (SIGKILL crash-restarts the server and wipes shared memory, so the exit callback can never be observed), use a plain bigint key in the fixture (see table_async fails for tables with serial/bigserial columns (sequence not pre-created) #33), and a 2M-row fixture so the copy outlasts the signal.
  • src/pgclone_bgw.c: add an interrupt check inside the COPY loop. Previously a single-table job ignored SIGTERM until the copy finished (and server shutdown waited for it).
  • src/pgclone_compat.h: new PGCLONE_CHECK_SHUTDOWN(). On PG17+ the worker SIGTERM handler is SignalHandlerForShutdownRequest, which only sets ShutdownRequestPending; CHECK_FOR_INTERRUPTS() never services it, so workers ignored SIGTERM on PG17/18 entirely. The macro checks that flag too. It is used at all interrupt checks in pgclone_bgw.c.

Testing

Full ./test/run_all.sh incl. chaos (PASS=5 FAIL=0):

  • PG14, 17, 18: pass with the final code.
  • PG15, 16: pass (chaos 5/5) on the earlier commit with a 200k-row fixture; not re-run after the PG17 macro and 2M-row fixture changes (the macro is identical to CHECK_FOR_INTERRUPTS() below PG17).

Before this PR, chaos was PASS=3 FAIL=2 on every version, and the "passes" were vacuous (no worker pid was found, so nothing was killed).

Notes

🤖 Generated with Claude Code

- test_chaos.sh: read worker/coordinator pids from pg_stat_activity (jobs_view has no worker_pid), use SIGTERM instead of SIGKILL (SIGKILL crash-restarts the server and wipes shared memory), and use a plain bigint key in the fixture.
- pgclone_bgw.c: CHECK_FOR_INTERRUPTS() in the COPY loop so SIGTERM/shutdown stops a single-table copy and the exit callback marks the slot FAILED.
On PG17+ the worker SIGTERM handler is SignalHandlerForShutdownRequest, which only sets ShutdownRequestPending; CHECK_FOR_INTERRUPTS() never services it. Add PGCLONE_CHECK_SHUTDOWN() (tests the flag on PG17+) and use it at every interrupt check in pgclone_bgw.c. Raise the chaos fixture to 2M rows so the copy outlasts the signal.
@valehdba
valehdba merged commit 014bddd into main Nov 17, 2026
22 checks passed
@valehdba
valehdba deleted the fix/chaos-tests branch November 17, 2026 07:49
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.

1 participant