OpenViking
OpenViking copied to clipboard
[Bug] Delta table grows unbounded (9.2 GB / 1.23 M records); startup delta replay OOMs container (exit 137); truncation only runs on create_index
Environment
- OpenViking 0.5.0, local collection, flat index, 1024-dim, int8 quant
- ~142K candidates (~0.85 GB live data); after a full
semantic_and_vectorsreindex of 150 watch targets the delta table grew to 1,232,801 records / 9.2 GB - Container memory limit 24 GB
What happened
- After the full reindex, the collection store grew from 517 MB to 12 GB. Table breakdown: C (candidates) 142,199 rows / 0.85 GB; D (delta) 1,232,801 rows / 9.2 GB; T (TTL) 0.
- On every restart,
LocalCollection._recover()replaysget_delta_data_after_ts(newest_version). 284,394 delta records (2.24 GB) had accumulated after the last snapshot, almost all pure PUT records. The replay loop in_recover()appends PUTs toupsert_listand only flushes when a DEL record appears, so with an all-PUT stream the entire 284K records accumulate as Python objects (_processedstays 0; log:Delta replay progress: 0/265187 records). RSS climbs linearly and the container is OOM-killed (exit 137) ~165 s after start, producing an endless crash loop. - The 948,407 delta records older than the newest snapshot (~7 GB) are never read again, but
_delete_expire_delta_record()is only invoked fromcreate_index()(local_collection.py:438), never during steady-state operation, so the delta table grows unboundedly.
Evidence
- Crash log:
Delta replay progress: 0/265187 records for index 'default'then exit 137 - RSS curve: linear climb 1.5 GiB → 23.6 GiB in ~130 s (5 s sampling), killed at the 24 GiB limit
- After offline deletion of all 1,232,801 delta records (no other change): startup RSS stable at 0.8 GiB, retrieval unchanged (hit@5 = 15/30, identical to the pre-fix baseline on a 30-query Chinese code-retrieval benchmark)
Suggested fixes
- Truncate deltas older than the oldest index snapshot in steady state (e.g., after each successful persist cycle), not only at
create_index. - Flush
upsert_list/delete_listin_recover()in bounded batches so replay memory is bounded regardless of stream shape. - Compact/truncate the delta table after bulk reindex operations.
Related: #6186
I opened #6268: https://github.com/volcengine/OpenViking/pull/6268
_recover() currently buffers all PUT delta records until the first DELETE, so an all-PUT backlog is materialized in memory and can OOM the process during startup. The PR flushes PUT/DELETE batches at a bounded size (1024) while preserving delta order.
Delta pruning after snapshots already runs through lush_all_indexes() on current main; this PR targets the remaining recovery-replay crash loop.