You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/context/architecture/archive.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,22 @@ latency cannot delay it. The separate `archive_body_stored` completion event car
158
158
`call_ref`. A failed R2 upload followed by a committed DB copy is not dropped. R2-only upload
159
159
failure still records a hash-only snapshot and statistics. These remain best-effort background
160
160
writes: a killed process can lose completion events, but cannot withhold the calling event.
161
+
The same completion event measures archive stages, including elapsed work on timeout or cancellation:
162
+
163
+
| Fields (milliseconds) | Scope |
164
+
| --- | --- |
165
+
|`compare_sem_wait_ms`, `compare_ms`| Precomparison slot wait, then pointer queries/reads and any JSON normalization. Both precede the DB write deadline. |
166
+
|`record_key_wait_ms`, `record_sem_wait_ms`| Same-key lock wait, then write-slot wait, inside the DB write deadline. |
167
+
|`record_db_ms`| Wall time while holding the write slot: pool checkout, body packing, SQL/commit, and integrity retries/backoff. This is not pure SQL time. |
168
+
|`observe_sem_wait_ms`, `observe_ms`| Optional post-commit change-report slot wait and work, outside the DB write deadline. |
169
+
170
+
Unentered phases are `null`. `failure_phase` names the measured phase interrupted by an escaping
171
+
exception (including cancellation); it is `null` when none was interrupted, including a queue
172
+
rejection before recording starts. Internally handled comparison failures still fall back to raw
173
+
hashes and use the existing counters. A post-commit observation cancellation does not mean the
174
+
snapshot was lost: `storage`/`dropped` continue to describe the committed write. Timings add no
175
+
DB writes or per-call events and do not change deadlines, the two archive slots, or pool sizes.
176
+
161
177
Stats count snapshots with recoverable bodies in DB or R2, including deduplicated versions;
162
178
`kept_bytes` is logical retained response bytes, not PostgreSQL physical table size.
163
179
@@ -751,8 +767,11 @@ Deleting `items[*].request_id` keeps all elements; deleting `items[*]` deletes t
751
767
Comparison has no six-level reporting limit and never uses reported/truncated paths as policy.
752
768
753
769
`_ignored_matches` preloads at most the latest and decisive snapshot bodies before the DB write.
754
-
It skips body reads for identical raw hashes. Pointer sessions close before object I/O. The pre-read
755
-
uses the shared archive semaphore and a three-second budget, separate from the write deadline.
770
+
It checks the key and raw hashes first, skipping new-response JSON normalization unless a differing
771
+
candidate has a readable body pointer. New keys and raw-identical baselines therefore need no
772
+
normalization; identical raw hashes also skip body reads. Pointer sessions close before JSON
773
+
normalization or object I/O. The pre-read uses the shared archive semaphore and a three-second
774
+
budget, separate from the write deadline.
756
775
Only matched snapshot IDs are passed to `_store_locked`; a concurrently changed baseline falls
757
776
back to raw hashes without holding a row lock across I/O or adding a reconciliation write.
758
777
`ignore_body_unavailable` and `ignore_comparison_failed` retain their diagnostic names for both
0 commit comments