fix: LB и на [::1] — localhost на Windows стоил 2 с на запрос; сдвиг цели failover

Найдено первым прогоном из чистого clone: make test-failover (BASE_URL
по умолчанию http://localhost:8080) успел сделать 8 записей за 15 с, и
первая успешная запись после хука пришла на 8,4 с. Windows сначала
стучится на ::1, где порт не был опубликован, и каждое новое соединение
ждёт ~2 с. LB теперь опубликован на 127.0.0.1 и [::1] (оба loopback):
0,013 с на запрос. Тест политики портов допускает только loopback.

collect_evidence: публичный тест всегда выбирает реплику, обслужившую
его первый POST, а последовательность запросов фиксирована — перед
каждым следующим прогоном rotation сдвигается лишними GET, чтобы
по очереди останавливались обе реплики.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexey Bodanyuk
2026-10-19 18:09:12 +03:00
co-authored by Claude Opus 5.5
parent 2846cae118
commit 27087326d0
4 changed files with 16 additions and 5 deletions
+6 -2
View File
@@ -5,7 +5,7 @@
# docker compose --env-file .env up -d --build --wait
# Order: postgres/valkey healthy -> migrate (ONE run, exits 0) -> api replicas healthy -> lb.
# Images are pinned by version AND digest. Passwords are passed only as secret files, and
# every service gets only the secrets it needs. Only the LB publishes ports (127.0.0.1 only).
# every service gets only the secrets it needs. Only the LB publishes ports (loopback only).
# Two networks: `edge` (lb <-> api) and `data` (api/migrate <-> postgres/valkey, internal):
# the LB cannot reach the stores, and the stores are not reachable from the edge.
name: mtusi-lab3
@@ -143,7 +143,11 @@ services:
volumes:
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- "127.0.0.1:${APP_PUBLISH_PORT:-8080}:8080" # the ONLY public entry point
# The ONLY public entry point, on the loopback interfaces only. Both IPv4 and IPv6:
# on Windows `localhost` resolves to ::1 first, and a refused ::1 connection costs ~2 s
# per request before the fallback to 127.0.0.1 (measured: 2.0 s vs 0.007 s).
- "127.0.0.1:${APP_PUBLISH_PORT:-8080}:8080"
- "[::1]:${APP_PUBLISH_PORT:-8080}:8080"
- "127.0.0.1:${LB_STATS_PORT:-8404}:8404" # local status page (UP/DOWN of replicas)
healthcheck:
# Config is valid and the process answers; whether any API is ready is the LB's own job.