Лаб6 - оценка 4

This commit is contained in:
Rakshasa2
2026-11-19 18:40:32 +03:00
parent 470d9d6f1e
commit dbce1eb574
62 changed files with 6087 additions and 15 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p evidence
DC="docker compose --env-file .env"
{
echo "=== E. реестр failed и DLQ ==="
$DC exec -T postgres sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT id,attachment_id,status,attempts,last_error FROM attachment_jobs WHERE status='"'"'failed'"'"';"'
$DC exec -T broker redis-cli -n 1 XRANGE attachment_jobs_dlq - + COUNT 20
echo "=== replay: только failed, у которых attachment НЕ ready ==="
$DC exec -T postgres sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "
WITH cand AS (
SELECT j.id FROM attachment_jobs j
JOIN attachments a ON a.id = j.attachment_id
WHERE j.status = '"'"'failed'"'"' AND a.status <> '"'"'ready'"'"'
)
UPDATE attachment_jobs j
SET status='"'"'pending'"'"', attempts=0, last_error=NULL,
lease_until=NULL, leased_by=NULL, next_run_at=NOW(), updated_at=NOW()
FROM cand WHERE j.id = cand.id
RETURNING j.id, j.attachment_id;"'
$DC exec -T postgres sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "
UPDATE attachments a SET status='"'"'queued'"'"', error_code=NULL, updated_at=NOW()
FROM attachment_jobs j
WHERE j.attachment_id=a.id AND j.status='"'"'pending'"'"' AND a.status='"'"'failed'"'"'
RETURNING a.id;"'
} 2>&1 | tee evidence/E_replay.txt