Repository navigation
fix(index): validate preconditions before replacing a scalar index - #5316
hello-peter-tang wants to merge 1 commit into
Conversation
create_scalar_index ran the fragment and num_segments checks after the driver-side drop_index call used by the legacy IndexConfig workflow, so a call that failed validation left the dataset without its previous index. Run all non-destructive checks (fragment existence, fragment_ids membership, num_segments adjustment) before the replacement block, so the drop is the last thing that can happen. Add a regression test that pre-creates an index, calls replace=True with a nonexistent fragment id, and asserts the index is still listed for both the segment and legacy workflows.
|
Heads-up: the |
|
That includes |
|
Follow-up: the Could a maintainer approve the pending workflow run when you have a moment? The same jobs pass locally on this head — No rush, and I'm happy to address anything it surfaces once the run goes through. |
|
The PR Checks run for this fork PR has been pending workflow approval ( |
Problem
create_scalar_indexvalidated preconditions on both sides of the destructive driver-sidedrop_indexcall used by the legacyIndexConfigworkflow. Withreplace=True, a check that ran after the drop destroyed the existing index and then raised, leaving the dataset with no index and no rebuild.The string index types now go through the distributed segment workflow, which defers replacement to the workers and therefore happens to be safe for the
fragment_ids=[999]repro. The legacyIndexConfigpath still drops on the driver first, and that path reproduces the issue:Fix
Hoist every non-destructive check above the replacement block:
Dataset contains no fragments),fragment_idsmembership,num_segmentsadjustment.The drop is now the last thing that can happen before the build, so validation failures never touch the existing index. When the legacy workflow does drop and reload the dataset, fragments are re-read from the reloaded version (data fragments are unchanged by an index drop).
Tests
test_failed_validation_keeps_existing_indexis parametrized over both workflows (BTREEsegment workflow andIndexConfiglegacy workflow). It pre-creates an index, callsreplace=Truewith a nonexistent fragment id, assertsValueError, and asserts the original index is still present. The legacy case fails without this change (1 failed, 1 passed) and passes with it.Closes #5249