Bring the system changes of lab 3 from 61c0c28..72a1e57 onto the lab 4 code, resolving each conflict by meaning and keeping everything lab 4 added: - a message is posted with one SQL statement under the chat row lock, and the attachment links go into the same statement; a foreign key violation on the attachment link still answers 404 and leaves nothing behind. Text and the attachment list are checked before the write, an outsider gets 404 for both, as before the carry over; - the request pipeline counts the body bytes actually received against the limit of the route, so a chunked body over 1 MiB gets 413 and the upload route keeps its MAX_UPLOAD_BYTES limit; - a request cancelled at shutdown gets 503 unavailable in the contract format, the worker waits a second less than the rest of the shutdown budget, SHUTDOWN_TIMEOUT_SECONDS becomes 6 s and the stop hooks 7 s; - readiness sits behind a Readiness port with the draining flag in shared infrastructure, and the drain window is logged through Logger; - logout revokes through SessionRevocations and withdraws the mark when PostgreSQL rejects the delete; an empty cursor is 400; - EventBus.project is gone, the sweep test subscribes and waits on a queue; domain tests check attachment_list instead of Chat.post; - make up waits for every replica in the balancer, BASE_URL follows the lb port, the image is tagged by the compose project, retry-check and faults-evidence are added, detection runs three times, failover-each and rolling-update record the stand usage, CI checks numeric uids. down also takes the tools and reconcile profiles of lab 4. Track 1 tooling of lab 3 (scaling.py, its samplers, tools/ and the CPU pinning of api, lb, valkey and k6) stays out; stand-usage.sh queries the database size itself instead of the track 1 sampler. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
36 lines
2.1 KiB
Bash
Executable File
36 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
cli() { docker compose exec -T valkey sh -c "REDISCLI_AUTH=\"\$(sed -n 's/^requirepass //p' /run/secrets/valkey.conf)\" valkey-cli $1"; }
|
|
psql() { docker compose exec -T postgres psql -U messenger -d messenger -tA -c "$1"; }
|
|
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"
|
|
echo "\$ valkey-cli config get appendonly appendfsync maxmemory maxmemory-policy"
|
|
cli "config get appendonly" ; cli "config get appendfsync"; cli "config get maxmemory"; cli "config get maxmemory-policy"
|
|
echo "\$ valkey-cli info persistence | grep aof_enabled,aof_last_write_status"
|
|
cli "info persistence" | grep -E '^aof_enabled|^aof_last_write_status'
|
|
echo "\$ valkey-cli dbsize; info stats | grep keyspace"
|
|
cli dbsize
|
|
cli "info stats" | grep -E '^keyspace_(hits|misses)'
|
|
echo "\$ valkey-cli --scan --pattern 'session:*' и вид значения (хеш сокращён, значения не печатаются)"
|
|
revoked=0; cached=0; key=""; stored=""
|
|
for k in $(cli "--scan --pattern session:* --count 1000"); do
|
|
if [ "$(cli "get $k")" = "-" ]; then
|
|
revoked=$((revoked + 1)); printf '%.16s… отметка отзыва "-"\n' "$k"; continue
|
|
fi
|
|
cached=$((cached + 1)); printf '%.16s… сессия\n' "$k"
|
|
if [ -z "$key" ]; then
|
|
stored=$(psql "SELECT (extract(epoch FROM expires_at) * 1000)::bigint FROM sessions WHERE token_hash = decode('${k#session:}', 'hex')")
|
|
if [ -n "$stored" ]; then key=$k; fi
|
|
fi
|
|
done
|
|
echo "tombstones: $revoked, cached sessions: $cached"
|
|
if [ "$revoked" -eq 0 ] || [ -z "$key" ]; then
|
|
echo "нужны закэшированная сессия из БД и отметка отзыва: сначала make test" >&2
|
|
exit 1
|
|
fi
|
|
expires=$(cli "pexpiretime $key")
|
|
echo "\$ срок ключа кэша против срока сессии для $(printf '%.16s' "$key")…"
|
|
echo "valkey pexpiretime, ms: $expires"
|
|
echo "postgres expires_at, ms: $stored"
|
|
if [ "$expires" -le "$stored" ]; then echo "ключ не переживает сессию: да"; else echo "ключ не переживает сессию: НЕТ"; exit 1; fi
|