forked from mtusi2026/mtusi2026lab4
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
46 lines
2.6 KiB
Bash
Executable File
46 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
psql() { docker compose exec -T postgres psql -U messenger -d messenger -c "$1"; }
|
|
header() { echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"; }
|
|
counts="SELECT (SELECT count(*) FROM users) users, (SELECT count(*) FROM sessions) sessions, (SELECT count(*) FROM chats) chats, (SELECT count(*) FROM chat_members) members, (SELECT count(*) FROM messages) messages, (SELECT count(*) FROM idempotency_keys) keys, (SELECT count(*) FROM attachments) attachments, (SELECT count(*) FROM message_attachments) links, (SELECT count(*) FROM schema_migrations) versions"
|
|
kdf="SELECT substring(password_hash from '^[$]argon2id[$]v=[0-9]+[$]m=[0-9]+,t=[0-9]+,p=[0-9]+[$]') AS kdf_prefix, username = 'seed_author' AS seed_stub, count(*) AS users, min(length(password_hash)) AS min_length, max(length(password_hash)) AS max_length FROM users GROUP BY 1, 2 ORDER BY 2"
|
|
tokens="SELECT octet_length(token_hash) AS stored_bytes, count(*) AS sessions FROM sessions GROUP BY 1"
|
|
{
|
|
header
|
|
for table in users sessions chats chat_members messages idempotency_keys attachments message_attachments schema_migrations; do
|
|
echo "\$ psql -c '\\d+ $table'"
|
|
psql "\\d+ $table"
|
|
done
|
|
echo "\$ psql -c 'SELECT version, left(checksum, 12), applied_at FROM schema_migrations'"
|
|
psql "SELECT version, left(checksum, 12) AS checksum, applied_at FROM schema_migrations"
|
|
} > evidence/schema.txt
|
|
{
|
|
header
|
|
echo "\$ psql -c \"$counts\""
|
|
psql "$counts"
|
|
echo "\$ make migrate"
|
|
docker compose run --rm migrate 2>/dev/null
|
|
echo "\$ psql -c \"$counts\""
|
|
psql "$counts"
|
|
} > evidence/migrations.txt
|
|
{
|
|
header
|
|
echo "\$ psql -c \"$kdf\""
|
|
psql "$kdf"
|
|
echo "\$ psql -c \"$tokens\""
|
|
psql "$tokens"
|
|
} > evidence/kdf.txt
|
|
{
|
|
header
|
|
echo "\$ git ls-files secrets .env backups volumes"
|
|
git ls-files secrets .env backups volumes
|
|
echo "(пусто: секретов, .env, дампов и volumes в Git нет)"
|
|
echo "\$ git check-ignore -v secrets/database_url secrets/postgres_password secrets/s3_root_password secrets/s3_secret_access_key .env backups/"
|
|
git check-ignore -v secrets/database_url secrets/postgres_password secrets/s3_root_password secrets/s3_secret_access_key .env backups/
|
|
project=$(docker compose config --format json | python3 -c 'import json,sys; print(json.load(sys.stdin)["name"])')
|
|
echo "\$ docker volume ls --filter label=com.docker.compose.project=$project"
|
|
docker volume ls --filter "label=com.docker.compose.project=$project"
|
|
} > evidence/secrets.txt
|
|
echo "evidence/{schema,migrations,kdf,secrets}.txt обновлены"
|