mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-29 22:21:08 -05:00
Optimizations copy-on-write move points out of their source segments in memory; WAL replay can only re-derive those moves from the sources' on-disk pre-images. Destroying the replaced segments' files right at the swap breaks that: the moved copies may still sit unflushed in appendable segments, so a restart before they are persisted loses the points. Instead of dropping source data in finish_optimization, retire the segments. Their files survive until a flush proves the durable waterline covers the optimization, at which point flush_all destroys them. While the files remain on disk the WAL acknowledge is capped at the wrapped segment's persisted version, so every operation the files contradict (deletions in particular) is replayed and re-applied on restart. A crash in the meantime loads the retirees next to their replacement and load-time deduplication resolves the overlap. Optimizer tests that assert source files are gone now flush first to mature the retirees before counting/asserting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>