Repository navigation
fix: make chaos tests meaningful; honor SIGTERM in background workers (PG14-18) - #34
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test/test_chaos.sh: read worker/coordinator pids frompg_stat_activity(jobs_viewhas noworker_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 plainbigintkey 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: newPGCLONE_CHECK_SHUTDOWN(). On PG17+ the worker SIGTERM handler isSignalHandlerForShutdownRequest, which only setsShutdownRequestPending;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 inpgclone_bgw.c.Testing
Full
./test/run_all.shincl. chaos (PASS=5 FAIL=0):CHECK_FOR_INTERRUPTS()below PG17).Before this PR, chaos was
PASS=3 FAIL=2on every version, and the "passes" were vacuous (no worker pid was found, so nothing was killed).Notes
table_asyncdoes not pre-create sequences).🤖 Generated with Claude Code