From b588278923879591757159c906d3fc5bfb1c713d Mon Sep 17 00:00:00 2001 From: bot-backend Date: Fri, 21 Aug 2026 15:42:36 +0300 Subject: [PATCH] =?UTF-8?q?fix(ops):=20=D0=B4=D1=80=D0=B8=D0=BB=D0=BB=20?= =?UTF-8?q?=D0=B2=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B6=D0=B4=D0=B0=D0=BB=20=D0=91?= =?UTF-8?q?=D0=94=20=D0=BF=D0=BE=20=D1=81=D0=BE=D0=BA=D0=B5=D1=82=D1=83=20?= =?UTF-8?q?=D0=B8=20=D1=83=D0=BC=D0=B8=D1=80=D0=B0=D0=BB=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=80=D1=82=D0=B5=20=D0=BD=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=8F=D1=89=D0=B5=D0=B3=D0=BE=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ops/restore-drill.sh` проверял готовность через `pg_isready -U postgres`, то есть по unix-сокету. Образ postgres во время инициализации поднимает временный сервер, который на сокете уже отвечает "accepting connections". Проба зеленела посреди initdb, восстановление начиналось в этот временный сервер и погибало, как только entrypoint гасил его ради настоящего: [12:26:22Z] Restoring dump into 'drill' (ON_ERROR_STOP=1 ...) FATAL: terminating connection due to administrator command server closed the connection unexpectedly Воспроизведено на проде 2026-08-21 на живом дампе `tradein-20260821-013001`: падение через 6 секунд после старта. С `-h 127.0.0.1` тот же дамп проходит восстановление и доходит до сборки индексов — временный сервер TCP не слушает, поэтому по TCP проба зеленеет только на настоящем сервере. Ровно та же проба и ровно по той же причине уже стоит в `.forgejo/workflows/ci-tradein.yml:137-141`. Тот же дефект живёт и в `.forgejo/workflows/deploy-tradein.yml:718-721` — там его чинят в PR #3011, здесь не трогаю. Refs #2203, #2989 --- ops/restore-drill.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ops/restore-drill.sh b/ops/restore-drill.sh index 6424ef43..e272361d 100755 --- a/ops/restore-drill.sh +++ b/ops/restore-drill.sh @@ -113,7 +113,15 @@ log "Container up, mapped to 127.0.0.1:${host_port} (only reachable while this d log "Waiting for postgres to accept connections (timeout ${READY_TIMEOUT}s)..." ready=0 for _ in $(seq 1 "$READY_TIMEOUT"); do - if docker exec "$CONTAINER" pg_isready -U postgres >/dev/null 2>&1; then + # -h 127.0.0.1 is load-bearing, NOT cosmetic. The postgres image runs a + # TEMPORARY server during initialisation, and that server already answers + # "accepting connections" on the unix socket. Probing the socket therefore + # goes green mid-init; the restore starts against the temporary server and + # dies with "FATAL: terminating connection due to administrator command" + # the moment the entrypoint shuts it down to start the real one. The + # temporary server does NOT listen on TCP, so a TCP probe only goes green + # on the real server. Same reasoning, same fix as ci-tradein.yml:137-141. + if docker exec "$CONTAINER" pg_isready -h 127.0.0.1 -U postgres >/dev/null 2>&1; then ready=1 break fi -- 2.45.3