lab5: RabbitMQ, relay и worker в стенде; reconciler lab4 убран

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

broker: RabbitMQ 4.3.7 (тег+digest), quorum queue + DLX/DLQ из definitions, пользователи
relay (только publish в exchange) и worker (только consume), без management UI и портов.
relay: outbox -> publish с publisher confirm, reaper истёкших lease, страховка от потерянных
сообщений. worker: claim + heartbeat lease, варианты, публикация с fencing, ack после COMMIT,
graceful stop, уборка staging и мусора попыток. S3: два bucket и четыре identity
(admin, api, worker, auditor) с проверкой модели доступа в s3-init. Отдельная сеть queue.
Reconciler lab4 (трек прошлой лабы) удалён: его роль выполняет уборка по журналу попыток.
This commit is contained in:
Alexey Bodanyuk
2026-10-31 16:12:52 +03:00
parent 655f264104
commit bc32a50967
15 changed files with 1058 additions and 141 deletions
+34 -2
View File
@@ -24,6 +24,8 @@ S3_REGION=us-east-1
S3_BUCKET=messenger-attachments
S3_ACCESS_KEY_ID_FILE=/run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE=/run/secrets/s3_secret_access_key
# Lab 5: private staging bucket for originals accepted before 202 (API: Write; worker: Read+Write).
S3_STAGING_BUCKET=messenger-staging
# Contract limits (may be lowered, never raised above 10485760 / 40000000).
MAX_UPLOAD_BYTES=10485760
MAX_IMAGE_PIXELS=40000000
@@ -38,8 +40,33 @@ S3_TIMEOUT_SECONDS=3
# Janitor: 'pending' intents older than this are failed uploads (object + row removed).
PENDING_GRACE_SECONDS=900
JANITOR_INTERVAL_SECONDS=60
# Level 4 failure experiments only (after_s3_put, after_ready_commit); keep empty.
FAULT_POINTS=
# Lab 5: broker credentials are files too (relay and worker get their OWN RabbitMQ user/URL;
# secrets/broker_url_relay|worker are mounted as /run/secrets/broker_url). The API has none.
BROKER_URL_FILE=/run/secrets/broker_url
# Jobs processed at once by one worker = RabbitMQ prefetch; image child processes at once.
WORKER_CONCURRENCY=2
WORKER_REPLICAS=1
# Managed attempts (claims) per job, then failed/retry_exhausted; backoff = full jitter.
JOB_MAX_ATTEMPTS=5
JOB_RETRY_BASE_SECONDS=2
JOB_RETRY_MAX_SECONDS=60
# One attempt: hard time limit (child process killed) and the lease renewed by its heartbeat.
JOB_TIMEOUT_SECONDS=60
JOB_LEASE_SECONDS=30
# Address-space limit of the image child process (RLIMIT_AS).
IMAGE_MAX_MEMORY_MB=768
# Staging copy of a FAILED attachment is kept this long for a replay (ready: deleted at once).
STAGING_RETENTION_SECONDS=86400
# Objects of attempts that never published are deleted this long after the attempt ended.
ORPHAN_GRACE_SECONDS=600
# Queued job without a claim for this long gets a new outbox row (lost-message guard).
QUEUED_REPUBLISH_SECONDS=300
# Pipeline version of new uploads (track 2: versions 1, 2, 3 in src/messenger/pipeline.py).
PIPELINE_VERSION=1
# Failure experiments only, per service (see src/messenger/config.py FAULT_POINTS); keep empty.
API_FAULT_POINTS=
RELAY_FAULT_POINTS=
WORKER_FAULT_POINTS=
# Additional settings of this implementation (defaults shown; all optional):
LOG_LEVEL=info
DB_POOL_MIN=1
@@ -60,6 +87,11 @@ PG_CPUS=2.0
PG_MEMORY=1g
VALKEY_CPUS=0.5
LB_CPUS=1.0
BROKER_CPUS=1.0
BROKER_MEMORY=512m
WORKER_CPUS=2.0
WORKER_MEMORY=1536m
RELAY_CPUS=0.5
PG_MAX_CONNECTIONS=100
# Host ports of the load balancer (published on 127.0.0.1 only; API replicas publish nothing)
APP_PUBLISH_PORT=8080