fix(vector): publish backups without replacement

This commit is contained in:
2026-07-12 02:32:32 +02:00
parent 015c496bda
commit 407c4a6faf
3 changed files with 30 additions and 1 deletions
@@ -13,6 +13,9 @@ cat >"$fakebin/pg_dump" <<'SH'
set -eu
for arg in "$@"; do case "$arg" in --file=*) output=${arg#--file=} ;; esac; done
printf 'custom dump' >"$output"
if [ -n "${RACE_OUTPUT:-}" ]; then
printf 'concurrent owner' >"$RACE_OUTPUT"
fi
SH
chmod 0755 "$fakebin/pg_dump"
@@ -26,6 +29,19 @@ test "$(cat "$victim")" = sentinel
test "$(cat "$output")" = 'custom dump'
test -L "$output.partial"
race_output="$tmp/raced.dump"
if PATH="$fakebin:$PATH" RACE_OUTPUT="$race_output" ./scripts/vector-backup.sh \
--host source --database thoth --user admin --password-file "$tmp/password" \
--output "$race_output" >"$tmp/race.out" 2>"$tmp/race.err"; then
echo "backup replaced a destination created concurrently" >&2
exit 1
fi
test "$(cat "$race_output")" = 'concurrent owner'
if find "$tmp" -name '.raced.dump.tmp.*' -print | grep -q .; then
echo "backup left its owned temporary archive after publication failure" >&2
exit 1
fi
cat >"$fakebin/psql" <<'SH'
#!/bin/sh
set -eu