Implement durable S3 attachments and reconciliation

This commit is contained in:
Tmribob
2026-11-07 00:29:30 +03:00
parent ec540a1a72
commit 71d72c88b9
57 changed files with 4660 additions and 37 deletions
+1
View File
@@ -0,0 +1 @@
{"api_memory_bytes": {"baseline_before_test": 166031522, "growth": 120334582, "peak_sample": 286366104, "samples": 11}, "concurrency": 10, "elapsed_seconds": 25.312, "failed_uploads": 0, "latency_ms": {"p50": 24938.0, "p95": 25312.0, "p99": 25312.0}, "memory_method": "sum of docker stats for api-1 and api-2; baseline before requests, then repeat after a 100 ms wait", "payload_bytes_each": 8388608, "successful_rps": 0.395, "successful_uploads": 10}
+1
View File
@@ -0,0 +1 @@
anonymous_s3_list_status=403
+1
View File
@@ -0,0 +1 @@
{"final_dry_run": {"deleted_orphans": 0, "elapsed_ms": 88.209, "eligible_orphans": 0, "grace_seconds": 60, "metadata_rows": 53, "missing_metadata_objects": 0, "mode": "dry_run", "orphan_objects": 0, "s3_objects": 53, "safety": "missing metadata retained; fresh and referenced objects never deleted"}, "missing_apply": {"deleted_orphans": 0, "elapsed_ms": 106.908, "eligible_orphans": 0, "grace_seconds": 60, "metadata_rows": 53, "missing_metadata_objects": 1, "mode": "apply", "orphan_objects": 0, "s3_objects": 52, "safety": "missing metadata retained; fresh and referenced objects never deleted"}, "missing_download": {"error": "unavailable", "status": 503}, "missing_dry_run": {"deleted_orphans": 0, "elapsed_ms": 174.655, "eligible_orphans": 0, "grace_seconds": 60, "metadata_rows": 53, "missing_metadata_objects": 1, "mode": "dry_run", "orphan_objects": 0, "s3_objects": 52, "safety": "missing metadata retained; fresh and referenced objects never deleted"}, "restored_download": {"bytes_match": true, "status": 200}, "safety": "apply leaves missing PostgreSQL metadata intact; object was restored without metadata recreation"}
+18
View File
@@ -0,0 +1,18 @@
## Reconciler experiment — 2026-11-06
Synthetic unreferenced object `attachments/reconcile-orphan` was inserted directly
into the private S3 bucket. No PostgreSQL metadata row was created.
Dry-run immediately after insertion (`--grace-seconds 60`):
{"deleted_orphans":0,"eligible_orphans":0,"grace_seconds":60,"metadata_rows":8,"missing_metadata_objects":0,"mode":"dry_run","orphan_objects":1,"s3_objects":9}
Apply after the 60-second grace period:
{"deleted_orphans":1,"eligible_orphans":1,"grace_seconds":60,"metadata_rows":8,"missing_metadata_objects":0,"mode":"apply","orphan_objects":1,"s3_objects":9}
Final dry-run:
{"deleted_orphans":0,"eligible_orphans":0,"grace_seconds":60,"metadata_rows":8,"missing_metadata_objects":0,"mode":"dry_run","orphan_objects":0,"s3_objects":8}
The reconciler only deletes S3 keys under the generated `attachments/` prefix that
have no metadata and are older than the grace period. A missing S3 object is
reported but its metadata is retained for manual repair; referenced and fresh
objects are never candidates for deletion.