Лаб6 - оценка 4
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user