Skip to content

test: add regression test for scalar index training sort spill under bounded memory pool - #8128

Merged
westonpace merged 1 commit into
lance-format:mainfrom
lancedb-robot:backburner/ENT-992/btree-spill-repro-test
Aug 3, 2026
Merged

test: add regression test for scalar index training sort spill under bounded memory pool#8128
westonpace merged 1 commit into
lance-format:mainfrom
lancedb-robot:backburner/ENT-992/btree-spill-repro-test

Conversation

@lancedb-robot

Copy link
Copy Markdown
Collaborator

Training a BTREE scalar index sorts the whole column through DataFusion's external sort against a bounded FairSpillPool. Before #7675 sized the sort spill reservation to the pool ((pool / 3).min(40MiB)), the un-spillable merge phase requested DataFusion's default 10MB reservation, which could exceed the entire pool on small-pool / large-column configurations. Index creation then failed with ResourcesExhausted from ExternalSorterMerge (surfaced through lance-datafusion/src/chunker.rs), and the only workaround was bypassing spilling entirely via LANCE_BYPASS_SPILLING (unbounded memory).

This adds a regression test that trains a BTREE index over 36MiB of 64-byte strings with LANCE_MEM_POOL_SIZE=4MiB, forcing many spilled sort runs. Verified against history: the test fails with the exact ResourcesExhausted(ExternalSorterMerge) error at 18381f31 and passes from 18381f3 (#7675) onward, on both DataFusion 53 and 54. Runs in ~7s (debug).

The test lives in its own single-test integration binary because the training path resolves the pool size only from the process-global LANCE_MEM_POOL_SIZE; the test also asserts the resolved options (pool size, spilling enabled) so it fails loudly instead of passing vacuously if that plumbing changes.

…bounded memory pool

Training a BTREE index sorts the column through DataFusion's external sort
against a bounded FairSpillPool. Before the 40MB-capped sort spill
reservation sizing (lance-format#7675), the un-spillable merge phase could exhaust the
pool on large string columns (ResourcesExhausted from ExternalSorterMerge),
failing index creation unless LANCE_BYPASS_SPILLING was set. Add a test
that forces many spilled sort runs under a 4MiB pool to keep this path
covered.
@github-actions github-actions Bot added the chore label Aug 1, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate recommendation: approve. This focused end-to-end test guards a real bounded-pool failure at the BTREE training boundary: the workload exceeds the configured pool, exercises the value-sort path with spilling enabled, and passes under the pool-relative reservation fix. A lower-level sort test could expose spill metrics more directly, but it would not cover the index-training wiring this regression protects.

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@westonpace
westonpace merged commit a2f9299 into lance-format:main Aug 3, 2026
40 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants