Skip to content

Commit 920bb63

Browse files
brainrakeclaude
andauthored
fix(pg_upgrade): root the target binaries so a gc cannot remove them (#2540)
Refs: MPG-1338 Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent e3f689e commit 920bb63

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • ansible/files/admin_api_scripts/pg_upgrade_scripts

‎ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,10 @@ EXTRA_NIX_CONF
430430

431431
log "Store path: $STORE_PATH"
432432

433-
# Realize the closure from the binary cache.
433+
# Realize the closure from the binary cache and root it in the pg-upgrade
434+
# profile, so a GC can't remove it mid-upgrade.
434435
#
435-
# nix-store -r can stall indefinitely on a dropped S3 connection without
436+
# The fetch can stall indefinitely on a dropped S3 connection without
436437
# erroring out (its own download timeout doesn't reliably fire), so guard each
437438
# attempt with a timeout and retry. Each path downloads atomically: already-
438439
# registered paths are skipped on retry but an in-flight NAR restarts from
@@ -447,14 +448,14 @@ EXTRA_NIX_CONF
447448

448449
nix_store_ok="false"
449450
for attempt in 1 2 3; do
450-
if timeout -k 10s 120s nix-store -r --quiet "$STORE_PATH"; then
451+
if timeout -k 10s 120s nix-env --option stalled-download-timeout 60 --profile /nix/var/nix/profiles/pg-upgrade --set "$STORE_PATH"; then
451452
nix_store_ok="true"
452453
break
453454
fi
454455
if [ "$attempt" -lt 3 ]; then
455-
log "WARNING: nix-store -r attempt ${attempt}/3 for $STORE_PATH failed or stalled (>=120s + up to 10s kill grace); retrying"
456+
log "WARNING: nix-env --set attempt ${attempt}/3 for $STORE_PATH failed or stalled (>=120s + up to 10s kill grace); retrying"
456457
else
457-
log "ERROR: nix-store -r failed after 3 attempts for $STORE_PATH"
458+
log "ERROR: nix-env --set failed after 3 attempts for $STORE_PATH"
458459
fi
459460
done
460461
[ "$nix_store_ok" = "true" ]

0 commit comments

Comments
 (0)