Prove attachment reconciliation under storage faults
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# Reconciliation fault injection and inventory cost
|
||||
|
||||
## Hypothesis
|
||||
|
||||
The reconciler can identify an orphan left by a successful S3 PUT followed by a failed PostgreSQL write, and a missing S3 object referenced by committed metadata. Applying repairs should delete only an orphan older than the grace period, restore missing bytes only from a matching fixture, and leave fresh or linked objects untouched. A second pass should find no work for the repaired cases.
|
||||
|
||||
## Reproduce
|
||||
|
||||
On the local Compose stand with `.env` configured, run `sh scripts/fault-injection.sh`. The local build used `COMPOSE_FILE=compose.yaml:compose.local.yaml` because this host needed a temporary Docker DNS override; the override is ignored by Git. The script builds and runs the maintenance service and writes anonymized JSON under `evidence/reconciliation/`. It uses a synthetic user, chat, message, attachments, and object keys. Repeated runs append more synthetic inventory to persistent volumes, so compare measurements only within one run.
|
||||
|
||||
The PostgreSQL fault is an invalid foreign key insert after a successful S3 PUT. The transaction rolls back, leaving an object with no metadata. The S3 fault deletes an object after its metadata commits. A 5-second grace period lets the test age the first orphan, then create a fresh one. Production maintenance defaults to one hour. A message links another attachment throughout the test.
|
||||
|
||||
## Observed result
|
||||
|
||||
Raw result: [run-20261002T111817Z.json](run-20261002T111817Z.json). The initial dry-run saw 283 metadata rows and 285 S3 objects, including the injected old orphan, fresh orphan, and missing object. The dry-run left them unchanged. A deliberately wrong source was rejected before deletion. Apply without a source deleted the old orphan, retained the missing metadata as a manual incident, and preserved the fresh and linked objects. A second dry-run found the old orphan gone and the missing incident present; a repeated delete made no change to the injected orphan. Apply with the correct fixture restored the exact SHA-256 bytes. Repeated restore returned `already_present`, and the final dry-run found neither injected inconsistency.
|
||||
|
||||
Inventory scans used three sequential dry-run trials per size in the same maintenance process. CPU is user plus system time for that process; RSS is Linux `VmRSS`, and high-water RSS is `ru_maxrss`. Times are milliseconds, RSS is KiB.
|
||||
|
||||
| Inventory | Trial wall times | Trial CPU times | Median wall | Median CPU | RSS before → after across trials | Peak RSS |
|
||||
| --- | --- | --- | ---: | ---: | --- | ---: |
|
||||
| 333 metadata / 334 objects | 19.390, 21.143, 23.322 | 6.447, 7.420, 8.516 | 21.143 | 7.420 | 68152 → 68512 | 126608 |
|
||||
| 533 metadata / 534 objects | 16.585, 24.219, 44.148 | 9.993, 9.997, 9.500 | 24.219 | 9.993 | 68512 → 68936 | 126608 |
|
||||
|
||||
The larger inventory used more CPU in this run; wall time varied widely, including one faster larger-inventory trial. These six samples on one local host do not establish a scaling law. The measurements exclude PostgreSQL and S3 server resources and include pre-existing data in persistent volumes. The process high-water RSS was reached before these scans, so it cannot isolate the scan's peak allocation; the before/after RSS readings show only retained process memory.
|
||||
@@ -0,0 +1 @@
|
||||
{"faults": {"apply_without_source": {"fresh_preserved": true, "linked_preserved": true, "missing_incident_retained": true, "old_deleted": true}, "post_delete_dry_run": {"missing_incident_retained": true, "old_absent": true}, "post_restore_dry_run": {"missing_absent": true, "old_absent": true}, "preview": {"fresh_detected": true, "inventory": {"metadata": 283, "objects": 285}, "linked_preserved": true, "missing_detected": true, "old_detected": true}, "repeat": "already_present", "repeat_delete_no_change": true, "restore": "restored", "wrong_fixture_rejected_without_delete": true}, "limits": "Single local host, 3 sequential dry-run scans per size; CPU/RSS are maintenance-process measurements only.", "measurements": [{"cpu_system_ms": 0.031, "cpu_user_ms": 6.416, "label": "plus_50", "metadata": 333, "objects": 334, "reconciler_ms": 19.349, "rss_after_kib": 68468, "rss_before_kib": 68152, "rss_hwm_kib": 126608, "trial": 1, "wall_ms": 19.39}, {"cpu_system_ms": 0.0, "cpu_user_ms": 7.42, "label": "plus_50", "metadata": 333, "objects": 334, "reconciler_ms": 21.098, "rss_after_kib": 68500, "rss_before_kib": 68468, "rss_hwm_kib": 126608, "trial": 2, "wall_ms": 21.143}, {"cpu_system_ms": 0.02, "cpu_user_ms": 8.496, "label": "plus_50", "metadata": 333, "objects": 334, "reconciler_ms": 23.282, "rss_after_kib": 68512, "rss_before_kib": 68500, "rss_hwm_kib": 126608, "trial": 3, "wall_ms": 23.322}, {"cpu_system_ms": 0.993, "cpu_user_ms": 9.0, "label": "plus_250", "metadata": 533, "objects": 534, "reconciler_ms": 16.523, "rss_after_kib": 68908, "rss_before_kib": 68512, "rss_hwm_kib": 126608, "trial": 1, "wall_ms": 16.585}, {"cpu_system_ms": 0.007, "cpu_user_ms": 9.99, "label": "plus_250", "metadata": 533, "objects": 534, "reconciler_ms": 24.163, "rss_after_kib": 68936, "rss_before_kib": 68908, "rss_hwm_kib": 126608, "trial": 2, "wall_ms": 24.219}, {"cpu_system_ms": 0.0, "cpu_user_ms": 9.5, "label": "plus_250", "metadata": 533, "objects": 534, "reconciler_ms": 44.084, "rss_after_kib": 68936, "rss_before_kib": 68936, "rss_hwm_kib": 126608, "trial": 3, "wall_ms": 44.148}], "summary": {"plus_250": {"median_cpu_ms": 9.993, "median_wall_ms": 24.219, "metadata": 533, "objects": 534}, "plus_50": {"median_cpu_ms": 7.42, "median_wall_ms": 21.143, "metadata": 333, "objects": 334}}}
|
||||
Reference in New Issue
Block a user