fix: persist frag reuse index external file on local filesystem#6163
Conversation
When `FragReuseIndexDetails` exceeds 204800 bytes, it is written to an external file (`details.binpb`). On local object stores, `ObjectStore::create` returns a `LocalWriter` that writes to a temp file and calls `persist()` in `Writer::shutdown` to rename it to the final path. The code imported `tokio::io::AsyncWriteExt` but not `lance_io::traits::Writer`, so `writer.shutdown()` resolved to `AsyncWriteExt::shutdown` (flush/close only), and the temp file was silently deleted on drop. Use UFCS to call `Writer::shutdown` explicitly, matching the existing pattern in `ivf.rs`. Fixes lance-format#6161 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReviewClean, well-targeted bugfix. The root cause analysis is spot-on: The regression test is well-constructed — it creates enough fragments to exceed the 204800-byte inline threshold and verifies the external file round-trips correctly. No issues found. LGTM. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Yikes, I wonder if there is any way we can rework our code to avoid this? Maybe |
|
Or maybe we can put the rename inside of |
@westonpace You are right, we can remove this footgun. I've just pushed a fix that does that. |
Previously, when
FragReuseIndexDetailsexceeded 204800 bytes (triggered by large compactions with many fragments), the code wrote the details to an external file (details.binpb). On local filesystems,ObjectStore::createreturns aLocalWriterthat atomically renames a temp file to the final path inWriter::shutdown. However,frag_reuse.rsimportedtokio::io::AsyncWriteExtbut notlance_io::traits::Writer, sowriter.shutdown()resolved toAsyncWriteExt::shutdown(flush/close only) — the temp file was deleted on drop without being persisted. Any subsequentload_indicescall would fail withNot found: .../details.binpb.Fixed by using UFCS
Writer::shutdown(writer.as_mut()).await?to explicitly call the lance trait method, matching the existing pattern inivf.rsandblob.rs.Fixes #6161