[Bug]: File descriptor exhaustion during segment rollover duplicates documents and leaves the collection unwritable
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
Description
When creating the next writing segment fails, the old segment can remain both in the segment manager and in writing_segment_. stats() and query() then count its documents twice. Later inserts fail, and the broken state can survive a close and reopen. Some documents whose insert returned an error become visible through a forward scan after reopening.
switch_to_new_segment_for_writing() dumps the old segment and adds it to the segment manager before Segment::CreateAndOpen() creates its replacement. A replacement-creation failure returns without undoing either step. get_all_segments_unsafe() lists both owners.
Steps to Reproduce
Reproduced on unmodified 98aa126, macOS arm64, through the C++ API with default collection options:
- Create a collection with an inverted-indexed string field
clsand a plain integer fieldn. Insert 1,000 documents withcls = 'a'andn = 1, then close it. - Open it and lower the process's soft
RLIMIT_NOFILEto the number of open descriptors plus a small allowance. The verifier swept allowances from 4 to 30 in fresh processes. - Call
optimize(). Opening the new segment's scalar index fails withEMFILE("Too many open files"). Restore the descriptor limit. - Compare
stats().doc_countwith the row count and distinct primary keys fromquery(cls = 'a'). Try another insert and anotheroptimize(), then close and reopen. - Query both
cls = 'a'and the plain fieldn. Try more inserts and query their plain-field values.
Logs / Stack Trace
At allowance 4 on 98aa126:
optimize: Failed to open scalar indexer
stats().doc_count: 2000
query(cls = 'a'): 2000 rows, 1000 distinct primary keys
insert(x0): failed, empty error message
second optimize: Segment has been dumped.
close: OK
reopen: doc_count=1001, query(cls = 'a') returns 1000 rows
query(n = 7): returns x0, whose insert failed
insert(y0), insert(y1), insert(y2): failed, empty error messages
query(n = 101): returns y1, whose insert failed
Expected: a failed replacement creation leaves each acknowledged document visible once, does not publish a rejected insert, and permits writes and a rollover retry after resources are available. The same consistency must hold after reopening.
Operating System
macOS 27.0.1, arm64. Linux and Windows were not run.
Build & Runtime Environment
C++ API, Apple clang, CMake Release. The independent reproduction used unmodified 98aa126. The fix tests used the cached 98aa126 source with all six #790 files and the rollover addition checked byte-for-byte against the PR branch. Current main was not built because its unrelated RaBitQ 0.3.8 dependency was unavailable locally.
Additional Context
The fix creates the replacement before dumping the old segment, and adds the old segment to the segment manager only when the replacement is ready. It retires failed replacement creations through the existing segment lifecycle, leaves pre-existing conflicting directories untouched, and adds no on-disk format, public API or persistent structure.
A test-only RLIMIT_NOFILE regression covers rollover from a full-segment insert, optimize(), and create_index(). It checks two successive failed creations, cleanup of their unused directories, indexed queries, an unconditional forward scan after index creation, unique primary keys, retry, writes, and reopening. A seventh case checks the results of a batch whose rollover fails after a successful prefix. The updated regression fails all seven cases on 8944774 and passes all seven with the finished fix. The final targeted run passed 293 cases, including the seven regressions; one exhaustive manifest-truncation case timed out at 60 seconds, as it also did on unchanged 8944774. No timeout is counted as a pass. Linux and Windows were not run.
The fix is part of #790.
- 主要言語
- C++
- スター
- 16.3k
- フォーク
- 1k
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 32
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
alibaba/zvec のほかの issue
-
[Feature]: IVF_TIEREDQ index type, with a learned variable-bit codec (25–44% less index memory than `IVF_RABITQ` at equal recall)対応中かも @richyreachy が 7 日前に担当しました。 オープンfeature
メンテナーはふだん 1 日以内に返信
-
Support an opt-in portable x86 FastPFOR build without SSE4.1対応中かも @egolearner が 20 日前に担当しました。 オープン
alibaba/zvec#875 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Enhance]: Reduce vector index block fragmentation caused by frequent flushes対応中かも @feihongxu0824 が 22 日前に担当しました。 オープンenhancement
メンテナーはふだん 1 日以内に返信
-
[Performance]:High-selectivity range filter materializes a full bitmap — `bitset_set_list` ~49% CPU, dwarfing the ANN search対応中かも @zhourrr が 22 日前に担当しました。 オープンenhancement
alibaba/zvec#868 · コメント 13 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Performance] Warm-query latency on small collections with query() and query_internal_ids() in v0.8.0再び着手できるかも @egolearner が 33 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
deprecation internal refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
realloc(ptr, 0) on glibc leaves the freed block in the capture as a leak対応中かも @ADAMAMZAR が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
bloomberg/memray#1097 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
new-compilers request
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
compiler-explorer/compiler-explorer#9640 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
deepseek-ai/DeepEP#839 ·
メンテナーはふだん 6 日以内に返信