Repository navigation
fix(table): bound out-of-order audit-chain walk to prevent full-copy OOM - #1122
Conversation
During replication full-copy catch-up, Table.commit's out-of-order
reconciliation walked the entire backward audit-history chain per record,
synchronously, buffering intermediate records in the JS heap. Peak heap scaled
with audit-history depth times worker count and OOM-killed the worker.
- Materialize each patch value during the walk and retain only { version, value }
so the backing transaction-log buffer and decoders are released immediately,
instead of pinning the full audit records for the whole walk.
- Cap the walk at MAX_OUT_OF_ORDER_AUDIT_DEPTH (RocksDB only, where the OOM was
observed). Beyond it, reconcile against the retained most-recent window via the
existing rebuildUpdateBefore fold and rule out duplicate re-delivery with an
O(1) lookup at txnTime so commutative ops are not double-applied. LMDB keeps its
exact unbounded walk.
Refs #1114
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request addresses an out-of-memory (OOM) issue (#1114) caused by pathologically deep audit chains during out-of-order write reconciliation in RocksDB. It introduces a depth cap of 1000 steps to bound the audit-chain walk and optimizes memory usage by retaining only the necessary version and value fields of succeeding updates instead of full audit records. Additionally, it adds duplicate detection for capped walks to prevent double-applying re-delivered commutative operations. Corresponding regression tests have been added to verify the bounded walk and duplicate prevention. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Cherry-pick of #1116 for v5.0.26 patch release.