Skip to content

bug: vector index builds leak their shuffle scratch directory #8992

Closed

Description

@LuciferYang

Every vector index build leaves its shuffle scratch directory behind in the OS temp directory. Nothing removes it, so a process that builds indexes repeatedly accumulates one directory per build.

Reproduced on abcd800cd by pointing TMPDIR at an empty directory and running a single index build:

$ mkdir -p /tmp/probe
$ TMPDIR=/tmp/probe cargo test -p lance --lib \
    index::vector::tests::test_initialize_vector_index_ivf_pq -- --exact
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3382 filtered out

$ find /tmp/probe
/tmp/probe
/tmp/probe/.tmp1hB7Tu
/tmp/probe/.tmp1hB7Tu/shuffle_data.lance
/tmp/probe/.tmp1hB7Tu/shuffle_data.spill
/tmp/probe/.tmp1hB7Tu/shuffle_offsets.lance
/tmp/probe/.tmp1hB7Tu/shuffle_offsets.spill

The test process exited normally and the directory is still there.

prepare_vector_segment_build creates the scratch directory as a local TempStdDir (rust/lance/src/index/vector.rs:590), hands create_ivf_shuffler only its path, and returns the shuffler alone (:599). The guard drops when the function returns, so the directory is removed before anything has been written into it. The shuffle writer recreates it on the way to writing shuffle_data.lance, and from that point nothing owns it.

Both build paths go through that helper: build_vector_index_impl (:1006) and build_distributed_vector_index (:605). The incremental path (:1344) and the optimize path in index/vector/ivf.rs:759 keep their guards in the enclosing function scope, so they are not affected.

Each leaked directory holds a shuffled copy of the column that was indexed, so a long-running process that rebuilds indexes fills its temp filesystem with copies of its own data.

#6980 fixed the same thing for the legacy IVF_HNSW partition staging directory.

Activity

  1. added a commit that references this issue on Sep 15, 2026
    7f51716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions