Repository navigation
fix(pg_upgrade): do not leave the status file at running when complete.sh exits - #2748
Draft
idawson-sb wants to merge 1 commit into
Draft
idawson-sb wants to merge 1 commit into
idawson-sb wants to merge 1 commit into
Conversation
…e.sh exits complete.sh writes "running" to /tmp/pg-upgrade-status, but only an ERR trap sets the final status. An explicit exit, a set -u abort, or a TERM/INT signal skips that trap, so the file stays at "running". check.sh then reports a live upgrade, and the next complete.sh run bails with "Upgrade job already started". Add an EXIT trap, as initiate.sh has, that writes "failed" when the file still reads "running". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
Package version diffCompares built package versions in legacyPackages between this PR and the tip of the base branch, per system. aarch64-linux: Closure size: 372 -> 372 (2 paths added, 2 paths removed, delta +0, disk usage +624B).x86_64-linux: Closure size: 370 -> 370 (2 paths added, 2 paths removed, delta +0, disk usage +624B). |
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.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
complete.shwritesrunningto/tmp/pg-upgrade-statusat the start ofcomplete_pg_upgrade. Only the ERR trap (trap cleanup ERR) writes the final status. These exits skip the ERR trap:exitafter the file saysrunning;set -uabort on an unset variable;After one of these exits, the file stays at
runninguntil the host reboots.check.shthen reports a live upgrade, and the nextcomplete.shrun stops with "Upgrade job already started. Bailing."initiate.shalready handles this with an EXIT trap (on_exit) and TERM/INT traps.complete.shdoes not.What is the new behavior?
complete_pg_upgradesets an EXIT trap and TERM/INT traps just after it writesrunning. This is the same method asinitiate.sh.runningwhen the job exits,on_exitrunscleanup failed. This writesfailed, re-enables the timers, and sends the logs, as for any other failure.completeorfailed,on_exitdoes nothing.cleanupruns in a subshell, because it callsexit. A failed run then exits non-zero.Additional context
Test: I used a small script with the same shape as
complete.sh(set -eEuo pipefail, a top-level ERR trap, the job in a background function). This is the status file after each type of exit:completecompletefailedfailedexit 1runningfailedset -uabortrunningfailedrunningfailedNot tested yet:
complete.shrun on a host. I tested only the trap method in a copy of the script's shape.shfmt. It is not installed on my machine; CI checks it. I checked the syntax withbash -n.postgres_releaseversion bump? Please tell me if it does.No trap can run on SIGKILL or an OOM kill, so this change does not cover those cases.
🤖 Generated with Claude Code