lab5: исправления по ревью

Concurrent complete no longer deletes the shared verified source; admission is atomic and covers pending presign rows; relay reconciles queued jobs lost to dead-lettering; failed staging is protected until failed_retention; timestamps normalized to UTC; reprocess prefers the durable original and keeps job->attachment lock order; heartbeat errors no longer burn attempts; confirm timeout enforced; pinned images and sanitized health responses.
This commit is contained in:
Vladislav Kunetskiy
2026-10-30 23:13:44 +03:00
parent 4bdcac3dfa
commit 9d7a0acb5a
40 changed files with 592 additions and 521 deletions
+4 -3
View File
@@ -162,6 +162,7 @@ func run(cfg config.Config, log *slog.Logger) error {
ClaimTTL: cfg.Outbox.ClaimTTL,
Batch: cfg.Outbox.Batch,
ReaperInterval: cfg.Outbox.ReaperInterval,
ReconcileAfter: cfg.Outbox.ReconcileAfter,
Retention: cfg.Outbox.Retention,
}, log)
@@ -212,14 +213,14 @@ func healthServer(
defer cancel()
if err := store.Ping(ctx); err != nil {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable", "database": err.Error()})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}
if !pub.Connected() {
if err := pub.Connect(); err != nil {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable", "broker": err.Error()})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}
@@ -227,7 +228,7 @@ func healthServer(
oldest, err := relay.Health(ctx)
if err != nil {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable", "outbox": err.Error()})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}
+3 -6
View File
@@ -79,7 +79,6 @@ func run(cfg config.Config, log *slog.Logger) error {
RetryCap: cfg.Processing.RetryCap,
MaxUploadBytes: cfg.S3.MaxUploadBytes,
MaxImagePixels: cfg.S3.MaxImagePixels,
Owner: fmt.Sprintf("worker-%d", os.Getpid()),
}, log)
server := healthServer(cfg.Worker.HealthAddr, store, objectStore, workerInstance)
@@ -197,22 +196,20 @@ func healthServer(
defer cancel()
if err := store.Ping(ctx); err != nil {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable", "database": err.Error()})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}
if err := objectStore.Ping(ctx); err != nil {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable", "s3": err.Error()})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}
running, connected := workerInstance.Ready()
if !running || !connected {
writeHealth(w, http.StatusServiceUnavailable, map[string]any{
"status": "unavailable", "consumer": running, "broker": connected,
})
writeHealth(w, http.StatusServiceUnavailable, map[string]any{"status": "unavailable"})
return
}