Skip to content

fix(db): clean up retired segment directories on Windows - #676

Open
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:fix/issue-644-segment-cleanup
Open

fix(db): clean up retired segment directories on Windows#676
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:fix/issue-644-segment-cleanup

Conversation

@JalinWang

Copy link
Copy Markdown
Collaborator

Closes #644.

  • Release zvec-owned segment file handles before removing retired directories.
  • Treat physical cleanup as best-effort after the segment is logically retired.
  • Add regression tests for old-directory removal and Windows handle-blocked cleanup.

External handle case

In the uncommon case where another process, such as a backup or inspection tool, opens a segment file on Windows without FILE_SHARE_DELETE, Optimize() cannot immediately remove the old directory.

The optimization remains successful because the replacement segment and manifest are already committed. The leftover directory will be removed on a later read-write open by the recovery cleanup introduced in #674, after the external handle is released.

Linux normally does not encounter this case because an open or memory-mapped file can still be unlinked; its storage is reclaimed after the last reference is closed.

Tests: targeted collection_test cases pass on Windows.

@JalinWang
JalinWang marked this pull request as ready for review August 13, 2026 03:05
@JalinWang
JalinWang requested a review from zhourrr as a code owner August 13, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 磁盘随optimize次数线性膨胀

1 participant