Repository navigation
fix: make tombstone check PK-aware in PKPersistedBetween - #23868
Merged
mergify[bot] merged 3 commits intoMar 17, 2026
Merged
Conversation
…se positives - Replace coarse-grained HasTombstoneChanged with PK-level check - Add GetChangedTombstoneObjsBetween using tombstoneObjectDTSIndex - Extract tombstonePKExistsInRange for testability - Fix LinearSearchOffsetByValFactory varchar bug (pk vs vec) - Add unit and integration tests
XuPeng-SH
approved these changes
Mar 17, 2026
gouhongshen
approved these changes
Mar 17, 2026
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
…n#23868) HasTombstoneChanged is a table-level check that returns true if ANY tombstone object changed, causing false "txn need retry" errors during long-running IVF index builds. This PR replaces it with PK-aware tombstone checking: read PK column from changed tombstone objects and do exact match. Also fixes a varchar bug in LinearSearchOffsetByValFactory where the search closure compared keys against themselves instead of the target vector. Approved by: @XuPeng-SH, @gouhongshen
1 task done
2 of 7 tasks
XuPeng-SH
added a commit
that referenced
this pull request
Sep 7, 2026
## What type of PR is this? - [x] BUG - [x] Improvement - [ ] API-change - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #28357 This fixes the reproduced catalog tombstone-row bailout mechanism; keep the issue's original large-scale nightly acceptance separate from the focused evidence below. ## What this PR does / why we need it: ### Design intent and root cause #23868 (`728817e98f`) introduced PK-aware tombstone checks specifically to prevent unrelated catalog changes from restarting long IVF builds. However, `tombstonePKExistsInRange` still returned `changed=true` once selected objects contained more than 50,000 rows, **before checking the requested PK or row commit timestamp**. The selection includes physically created/deleted tombstone objects. Compaction can therefore select historical deletes unrelated to the requested catalog key; object row counts do not establish a logical metadata change. The consumer chain is `LockMeta -> LockRows -> PrimaryKeysMayBeModified -> PKPersistedBetween`. A conservative positive becomes an RC/definition retry, and `Compile.Run` rolls back/rebuilds the complete statement. A late index-update registration can consequently redo clustering and the entire mapping phase. The issue records three `tombstone_rows_bailout` retries during one client CREATE INDEX. That incident evidence and the deterministic source-level mechanism are consistent, but this PR does not independently identify every concurrent tombstone producer or prove that each historical target key was unchanged. ### Changes and preserved behavior - Thread the physical table ID into tombstone checking. The four canonical IDs recognized by `catalog.IsSystemTable` inspect copied PKs instead of using the row-count shortcut. No index-algorithm, table-name, account, or issue-specific special case. - Preserve the strict `>50,000` cost guard for user tables; count with `uint64`. - Use the existing 16-permit PK I/O semaphore for tombstone scans. The data phase releases its permit first; acquisition is never nested. Readers release each block before advancing, and the scan releases its permit with `defer` on every return. - Check the process context before scanning and between blocks. Propagate caller/process cancellation during reads instead of converting it into another apparent metadata-change retry. Ordinary read errors still conservatively return changed. - Preserve real PK hits, TN `(from, to]` and abort checks, conservative CN hits, unknown visibility handling, lock/version fences, and statement rollback semantics. Tombstones remain searched linearly by copied PK, not by their rowid sort order. ### Risks, performance, and deliberate limits This trades additional catalog validation I/O for avoiding a complete expensive statement restart. It is not a zero-cost change: a missing key scans selected tombstone blocks, with work proportional to that history and key search cost. The semaphore bounds concurrent block readers, not total elapsed time, object metadata, or the existing shared cache. Slow storage can still prolong a check; process cancellation remains the termination mechanism, and no new fixed timeout, worker, retry loop, cache, configuration, or logging stream is introduced. The existing `changed_objects_bailout` and `candidate_blocks_bailout` remain unchanged. Real conflicts and unavailable evidence may still require retries. This is **not** a blanket promise of zero catalog/DDL retries, nor a redesign of multi-phase index building. Prelocking alone would not close reentrant validation; suppressing the retry or retrying only the final REPLACE would weaken transaction/snapshot correctness. Local Darwin/arm64 Apple M4, Go 1.26.4, LocalFS (disabled MO caches, OS cache possible), three one-second microbenchmark samples: | Selected tombstone rows | Scan time/op | Allocated bytes/op | |---:|---:|---:| | 1 | 19–21 us | ~5.3 KB | | 50,000 | 0.78–0.83 ms | ~30 KB | | 50,001 | 0.76–0.86 ms | ~30 KB | | 100,000 | 1.59–2.24 ms | ~54 KB | These measure successful negative checks, not a comparison to the old incorrect constant-time bailout, not peak RSS, and not remote-S3/nightly latency. The 10M-row/768-dimensional/109-minute nightly was not rerun locally; no numeric end-to-end speedup is claimed. ### Validation and counterexamples Base: latest main `62770aedaa0cf3b5613bb7a42371bb08ef14ed5c`. Three changed files, production behavior localized to disttae. - **Red before green:** the same `PKPersistedBetween` regression using a real encoded 50,001-row TN tombstone object failed on `0b195e4f5a` with `tombstone_rows_bailout`: absent catalog keys and out-of-range deletes returned true; an already-cancelled context returned no error. It passes with the fix. - Reused lightweight file-service/process fixtures, no new cluster UT. Tests cover all canonical catalog policies, retained user-table guard, CN and TN objects, a real hit in the last block, compaction of historical deletes, open lower/closed upper timestamp boundaries, mpool accounting, read errors, cancellation before work/while awaiting a saturated permit/during I/O, permit release, and a successful subsequent check. Phase barriers, not sleeps, trigger cancellation; cleanup joins the worker and closes owned file services. - Full disttae normal suite passed (final run 8.238 s); full disttae race suite passed (final run 11.118 s). Focused cancellation race test measured 0.02 s, then ran 100 times in one process (final run 3.637 s). Existing tombstone and timestamp/abort tests remain enabled. - Full lockop consumer suite passed. `go vet` for disttae and `make -j8 build` passed. Native artifacts were built through the platform-aware `make cgo` owner, with verified source provenance. - Existing `vector_index_plugin_smoke.sql` ran in normal mo-tester comparison mode on a fresh, test-owned standalone service after SQL and ISCP readiness: **22/22 twice**, 0.262 s and 0.192 s. It validates HNSW/IVF creation, catalog metadata, SHOW CREATE, search, and rejection with the feature disabled. Database and table catalog residue were both zero after each run. No SQL/result files or mo-tester changes. An initial absolute dotted temporary-path invocation failed result-file discovery and executed no SQL; it is not counted as BVT evidence. - Rebased from `0b195e4f5a` to `62770aedaa` (only frontend clone/lineage locking and its tests changed upstream). Disttae and lockop suites were rerun after rebase; race/benchmark/IVF evidence is reused because those exercised paths and native inputs are unchanged. ### Review Self-review plus an independent read-only counterexample/ownership audit found no production blocker. Verified permit ownership across data/tombstone phases, no nested semaphore acquisition, and no reverse lock edge through tombstone I/O. No wire, persisted catalog format, configuration, or index implementation changes. The existing `PKPersistedBetween` process-context contract is unchanged; arbitrary contexts differing from `tbl.proc.Ctx` are not newly promised. | Audit | Ownership / termination | |---|---| | Q1: cleanup | Per-block readers release buffers; deferred scan permit release; test-owned FS/process cleanup and zero mpool residue | | Q2: waits | Non-nested semaphore admission observes context; readers receive that context; cancellation needs no metadata lock or semaphore permit | | Q3: growth | Existing 16-permit block-I/O admission; sequential block lifetime; no new queue, worker, retry state, or diagnostic cardinality; selected-object metadata remains snapshot-proportional | Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…rigin#28359) ## What type of PR is this? - [x] BUG - [x] Improvement - [ ] API-change - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28357 This fixes the reproduced catalog tombstone-row bailout mechanism; keep the issue's original large-scale nightly acceptance separate from the focused evidence below. ## What this PR does / why we need it: ### Design intent and root cause matrixorigin#23868 (`728817e98f`) introduced PK-aware tombstone checks specifically to prevent unrelated catalog changes from restarting long IVF builds. However, `tombstonePKExistsInRange` still returned `changed=true` once selected objects contained more than 50,000 rows, **before checking the requested PK or row commit timestamp**. The selection includes physically created/deleted tombstone objects. Compaction can therefore select historical deletes unrelated to the requested catalog key; object row counts do not establish a logical metadata change. The consumer chain is `LockMeta -> LockRows -> PrimaryKeysMayBeModified -> PKPersistedBetween`. A conservative positive becomes an RC/definition retry, and `Compile.Run` rolls back/rebuilds the complete statement. A late index-update registration can consequently redo clustering and the entire mapping phase. The issue records three `tombstone_rows_bailout` retries during one client CREATE INDEX. That incident evidence and the deterministic source-level mechanism are consistent, but this PR does not independently identify every concurrent tombstone producer or prove that each historical target key was unchanged. ### Changes and preserved behavior - Thread the physical table ID into tombstone checking. The four canonical IDs recognized by `catalog.IsSystemTable` inspect copied PKs instead of using the row-count shortcut. No index-algorithm, table-name, account, or issue-specific special case. - Preserve the strict `>50,000` cost guard for user tables; count with `uint64`. - Use the existing 16-permit PK I/O semaphore for tombstone scans. The data phase releases its permit first; acquisition is never nested. Readers release each block before advancing, and the scan releases its permit with `defer` on every return. - Check the process context before scanning and between blocks. Propagate caller/process cancellation during reads instead of converting it into another apparent metadata-change retry. Ordinary read errors still conservatively return changed. - Preserve real PK hits, TN `(from, to]` and abort checks, conservative CN hits, unknown visibility handling, lock/version fences, and statement rollback semantics. Tombstones remain searched linearly by copied PK, not by their rowid sort order. ### Risks, performance, and deliberate limits This trades additional catalog validation I/O for avoiding a complete expensive statement restart. It is not a zero-cost change: a missing key scans selected tombstone blocks, with work proportional to that history and key search cost. The semaphore bounds concurrent block readers, not total elapsed time, object metadata, or the existing shared cache. Slow storage can still prolong a check; process cancellation remains the termination mechanism, and no new fixed timeout, worker, retry loop, cache, configuration, or logging stream is introduced. The existing `changed_objects_bailout` and `candidate_blocks_bailout` remain unchanged. Real conflicts and unavailable evidence may still require retries. This is **not** a blanket promise of zero catalog/DDL retries, nor a redesign of multi-phase index building. Prelocking alone would not close reentrant validation; suppressing the retry or retrying only the final REPLACE would weaken transaction/snapshot correctness. Local Darwin/arm64 Apple M4, Go 1.26.4, LocalFS (disabled MO caches, OS cache possible), three one-second microbenchmark samples: | Selected tombstone rows | Scan time/op | Allocated bytes/op | |---:|---:|---:| | 1 | 19–21 us | ~5.3 KB | | 50,000 | 0.78–0.83 ms | ~30 KB | | 50,001 | 0.76–0.86 ms | ~30 KB | | 100,000 | 1.59–2.24 ms | ~54 KB | These measure successful negative checks, not a comparison to the old incorrect constant-time bailout, not peak RSS, and not remote-S3/nightly latency. The 10M-row/768-dimensional/109-minute nightly was not rerun locally; no numeric end-to-end speedup is claimed. ### Validation and counterexamples Base: latest main `62770aedaa0cf3b5613bb7a42371bb08ef14ed5c`. Three changed files, production behavior localized to disttae. - **Red before green:** the same `PKPersistedBetween` regression using a real encoded 50,001-row TN tombstone object failed on `0b195e4f5a` with `tombstone_rows_bailout`: absent catalog keys and out-of-range deletes returned true; an already-cancelled context returned no error. It passes with the fix. - Reused lightweight file-service/process fixtures, no new cluster UT. Tests cover all canonical catalog policies, retained user-table guard, CN and TN objects, a real hit in the last block, compaction of historical deletes, open lower/closed upper timestamp boundaries, mpool accounting, read errors, cancellation before work/while awaiting a saturated permit/during I/O, permit release, and a successful subsequent check. Phase barriers, not sleeps, trigger cancellation; cleanup joins the worker and closes owned file services. - Full disttae normal suite passed (final run 8.238 s); full disttae race suite passed (final run 11.118 s). Focused cancellation race test measured 0.02 s, then ran 100 times in one process (final run 3.637 s). Existing tombstone and timestamp/abort tests remain enabled. - Full lockop consumer suite passed. `go vet` for disttae and `make -j8 build` passed. Native artifacts were built through the platform-aware `make cgo` owner, with verified source provenance. - Existing `vector_index_plugin_smoke.sql` ran in normal mo-tester comparison mode on a fresh, test-owned standalone service after SQL and ISCP readiness: **22/22 twice**, 0.262 s and 0.192 s. It validates HNSW/IVF creation, catalog metadata, SHOW CREATE, search, and rejection with the feature disabled. Database and table catalog residue were both zero after each run. No SQL/result files or mo-tester changes. An initial absolute dotted temporary-path invocation failed result-file discovery and executed no SQL; it is not counted as BVT evidence. - Rebased from `0b195e4f5a` to `62770aedaa` (only frontend clone/lineage locking and its tests changed upstream). Disttae and lockop suites were rerun after rebase; race/benchmark/IVF evidence is reused because those exercised paths and native inputs are unchanged. ### Review Self-review plus an independent read-only counterexample/ownership audit found no production blocker. Verified permit ownership across data/tombstone phases, no nested semaphore acquisition, and no reverse lock edge through tombstone I/O. No wire, persisted catalog format, configuration, or index implementation changes. The existing `PKPersistedBetween` process-context contract is unchanged; arbitrary contexts differing from `tbl.proc.Ctx` are not newly promised. | Audit | Ownership / termination | |---|---| | Q1: cleanup | Per-block readers release buffers; deferred scan permit release; test-owned FS/process cleanup and zero mpool residue | | Q2: waits | Non-nested semaphore admission observes context; readers receive that context; cancellation needs no metadata lock or semaphore permit | | Q3: growth | Existing 16-permit block-I/O admission; sequential block lifetime; no new queue, worker, retry state, or diagnostic cardinality; selected-object metadata remains snapshot-proportional | Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…rigin#28359) ## What type of PR is this? - [x] BUG - [x] Improvement - [ ] API-change - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28357 This fixes the reproduced catalog tombstone-row bailout mechanism; keep the issue's original large-scale nightly acceptance separate from the focused evidence below. ## What this PR does / why we need it: ### Design intent and root cause matrixorigin#23868 (`728817e98f`) introduced PK-aware tombstone checks specifically to prevent unrelated catalog changes from restarting long IVF builds. However, `tombstonePKExistsInRange` still returned `changed=true` once selected objects contained more than 50,000 rows, **before checking the requested PK or row commit timestamp**. The selection includes physically created/deleted tombstone objects. Compaction can therefore select historical deletes unrelated to the requested catalog key; object row counts do not establish a logical metadata change. The consumer chain is `LockMeta -> LockRows -> PrimaryKeysMayBeModified -> PKPersistedBetween`. A conservative positive becomes an RC/definition retry, and `Compile.Run` rolls back/rebuilds the complete statement. A late index-update registration can consequently redo clustering and the entire mapping phase. The issue records three `tombstone_rows_bailout` retries during one client CREATE INDEX. That incident evidence and the deterministic source-level mechanism are consistent, but this PR does not independently identify every concurrent tombstone producer or prove that each historical target key was unchanged. ### Changes and preserved behavior - Thread the physical table ID into tombstone checking. The four canonical IDs recognized by `catalog.IsSystemTable` inspect copied PKs instead of using the row-count shortcut. No index-algorithm, table-name, account, or issue-specific special case. - Preserve the strict `>50,000` cost guard for user tables; count with `uint64`. - Use the existing 16-permit PK I/O semaphore for tombstone scans. The data phase releases its permit first; acquisition is never nested. Readers release each block before advancing, and the scan releases its permit with `defer` on every return. - Check the process context before scanning and between blocks. Propagate caller/process cancellation during reads instead of converting it into another apparent metadata-change retry. Ordinary read errors still conservatively return changed. - Preserve real PK hits, TN `(from, to]` and abort checks, conservative CN hits, unknown visibility handling, lock/version fences, and statement rollback semantics. Tombstones remain searched linearly by copied PK, not by their rowid sort order. ### Risks, performance, and deliberate limits This trades additional catalog validation I/O for avoiding a complete expensive statement restart. It is not a zero-cost change: a missing key scans selected tombstone blocks, with work proportional to that history and key search cost. The semaphore bounds concurrent block readers, not total elapsed time, object metadata, or the existing shared cache. Slow storage can still prolong a check; process cancellation remains the termination mechanism, and no new fixed timeout, worker, retry loop, cache, configuration, or logging stream is introduced. The existing `changed_objects_bailout` and `candidate_blocks_bailout` remain unchanged. Real conflicts and unavailable evidence may still require retries. This is **not** a blanket promise of zero catalog/DDL retries, nor a redesign of multi-phase index building. Prelocking alone would not close reentrant validation; suppressing the retry or retrying only the final REPLACE would weaken transaction/snapshot correctness. Local Darwin/arm64 Apple M4, Go 1.26.4, LocalFS (disabled MO caches, OS cache possible), three one-second microbenchmark samples: | Selected tombstone rows | Scan time/op | Allocated bytes/op | |---:|---:|---:| | 1 | 19–21 us | ~5.3 KB | | 50,000 | 0.78–0.83 ms | ~30 KB | | 50,001 | 0.76–0.86 ms | ~30 KB | | 100,000 | 1.59–2.24 ms | ~54 KB | These measure successful negative checks, not a comparison to the old incorrect constant-time bailout, not peak RSS, and not remote-S3/nightly latency. The 10M-row/768-dimensional/109-minute nightly was not rerun locally; no numeric end-to-end speedup is claimed. ### Validation and counterexamples Base: latest main `62770aedaa0cf3b5613bb7a42371bb08ef14ed5c`. Three changed files, production behavior localized to disttae. - **Red before green:** the same `PKPersistedBetween` regression using a real encoded 50,001-row TN tombstone object failed on `0b195e4f5a` with `tombstone_rows_bailout`: absent catalog keys and out-of-range deletes returned true; an already-cancelled context returned no error. It passes with the fix. - Reused lightweight file-service/process fixtures, no new cluster UT. Tests cover all canonical catalog policies, retained user-table guard, CN and TN objects, a real hit in the last block, compaction of historical deletes, open lower/closed upper timestamp boundaries, mpool accounting, read errors, cancellation before work/while awaiting a saturated permit/during I/O, permit release, and a successful subsequent check. Phase barriers, not sleeps, trigger cancellation; cleanup joins the worker and closes owned file services. - Full disttae normal suite passed (final run 8.238 s); full disttae race suite passed (final run 11.118 s). Focused cancellation race test measured 0.02 s, then ran 100 times in one process (final run 3.637 s). Existing tombstone and timestamp/abort tests remain enabled. - Full lockop consumer suite passed. `go vet` for disttae and `make -j8 build` passed. Native artifacts were built through the platform-aware `make cgo` owner, with verified source provenance. - Existing `vector_index_plugin_smoke.sql` ran in normal mo-tester comparison mode on a fresh, test-owned standalone service after SQL and ISCP readiness: **22/22 twice**, 0.262 s and 0.192 s. It validates HNSW/IVF creation, catalog metadata, SHOW CREATE, search, and rejection with the feature disabled. Database and table catalog residue were both zero after each run. No SQL/result files or mo-tester changes. An initial absolute dotted temporary-path invocation failed result-file discovery and executed no SQL; it is not counted as BVT evidence. - Rebased from `0b195e4f5a` to `62770aedaa` (only frontend clone/lineage locking and its tests changed upstream). Disttae and lockop suites were rerun after rebase; race/benchmark/IVF evidence is reused because those exercised paths and native inputs are unchanged. ### Review Self-review plus an independent read-only counterexample/ownership audit found no production blocker. Verified permit ownership across data/tombstone phases, no nested semaphore acquisition, and no reverse lock edge through tombstone I/O. No wire, persisted catalog format, configuration, or index implementation changes. The existing `PKPersistedBetween` process-context contract is unchanged; arbitrary contexts differing from `tbl.proc.Ctx` are not newly promised. | Audit | Ownership / termination | |---|---| | Q1: cleanup | Per-block readers release buffers; deferred scan permit release; test-owned FS/process cleanup and zero mpool residue | | Q2: waits | Non-nested semaphore admission observes context; readers receive that context; cancellation needs no metadata lock or semaphore permit | | Q3: growth | Existing 16-permit block-I/O admission; sequential block lifetime; no new queue, worker, retry state, or diagnostic cardinality; selected-object metadata remains snapshot-proportional | Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…rigin#28359) ## What type of PR is this? - [x] BUG - [x] Improvement - [ ] API-change - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28357 This fixes the reproduced catalog tombstone-row bailout mechanism; keep the issue's original large-scale nightly acceptance separate from the focused evidence below. ## What this PR does / why we need it: ### Design intent and root cause matrixorigin#23868 (`728817e98f`) introduced PK-aware tombstone checks specifically to prevent unrelated catalog changes from restarting long IVF builds. However, `tombstonePKExistsInRange` still returned `changed=true` once selected objects contained more than 50,000 rows, **before checking the requested PK or row commit timestamp**. The selection includes physically created/deleted tombstone objects. Compaction can therefore select historical deletes unrelated to the requested catalog key; object row counts do not establish a logical metadata change. The consumer chain is `LockMeta -> LockRows -> PrimaryKeysMayBeModified -> PKPersistedBetween`. A conservative positive becomes an RC/definition retry, and `Compile.Run` rolls back/rebuilds the complete statement. A late index-update registration can consequently redo clustering and the entire mapping phase. The issue records three `tombstone_rows_bailout` retries during one client CREATE INDEX. That incident evidence and the deterministic source-level mechanism are consistent, but this PR does not independently identify every concurrent tombstone producer or prove that each historical target key was unchanged. ### Changes and preserved behavior - Thread the physical table ID into tombstone checking. The four canonical IDs recognized by `catalog.IsSystemTable` inspect copied PKs instead of using the row-count shortcut. No index-algorithm, table-name, account, or issue-specific special case. - Preserve the strict `>50,000` cost guard for user tables; count with `uint64`. - Use the existing 16-permit PK I/O semaphore for tombstone scans. The data phase releases its permit first; acquisition is never nested. Readers release each block before advancing, and the scan releases its permit with `defer` on every return. - Check the process context before scanning and between blocks. Propagate caller/process cancellation during reads instead of converting it into another apparent metadata-change retry. Ordinary read errors still conservatively return changed. - Preserve real PK hits, TN `(from, to]` and abort checks, conservative CN hits, unknown visibility handling, lock/version fences, and statement rollback semantics. Tombstones remain searched linearly by copied PK, not by their rowid sort order. ### Risks, performance, and deliberate limits This trades additional catalog validation I/O for avoiding a complete expensive statement restart. It is not a zero-cost change: a missing key scans selected tombstone blocks, with work proportional to that history and key search cost. The semaphore bounds concurrent block readers, not total elapsed time, object metadata, or the existing shared cache. Slow storage can still prolong a check; process cancellation remains the termination mechanism, and no new fixed timeout, worker, retry loop, cache, configuration, or logging stream is introduced. The existing `changed_objects_bailout` and `candidate_blocks_bailout` remain unchanged. Real conflicts and unavailable evidence may still require retries. This is **not** a blanket promise of zero catalog/DDL retries, nor a redesign of multi-phase index building. Prelocking alone would not close reentrant validation; suppressing the retry or retrying only the final REPLACE would weaken transaction/snapshot correctness. Local Darwin/arm64 Apple M4, Go 1.26.4, LocalFS (disabled MO caches, OS cache possible), three one-second microbenchmark samples: | Selected tombstone rows | Scan time/op | Allocated bytes/op | |---:|---:|---:| | 1 | 19–21 us | ~5.3 KB | | 50,000 | 0.78–0.83 ms | ~30 KB | | 50,001 | 0.76–0.86 ms | ~30 KB | | 100,000 | 1.59–2.24 ms | ~54 KB | These measure successful negative checks, not a comparison to the old incorrect constant-time bailout, not peak RSS, and not remote-S3/nightly latency. The 10M-row/768-dimensional/109-minute nightly was not rerun locally; no numeric end-to-end speedup is claimed. ### Validation and counterexamples Base: latest main `62770aedaa0cf3b5613bb7a42371bb08ef14ed5c`. Three changed files, production behavior localized to disttae. - **Red before green:** the same `PKPersistedBetween` regression using a real encoded 50,001-row TN tombstone object failed on `0b195e4f5a` with `tombstone_rows_bailout`: absent catalog keys and out-of-range deletes returned true; an already-cancelled context returned no error. It passes with the fix. - Reused lightweight file-service/process fixtures, no new cluster UT. Tests cover all canonical catalog policies, retained user-table guard, CN and TN objects, a real hit in the last block, compaction of historical deletes, open lower/closed upper timestamp boundaries, mpool accounting, read errors, cancellation before work/while awaiting a saturated permit/during I/O, permit release, and a successful subsequent check. Phase barriers, not sleeps, trigger cancellation; cleanup joins the worker and closes owned file services. - Full disttae normal suite passed (final run 8.238 s); full disttae race suite passed (final run 11.118 s). Focused cancellation race test measured 0.02 s, then ran 100 times in one process (final run 3.637 s). Existing tombstone and timestamp/abort tests remain enabled. - Full lockop consumer suite passed. `go vet` for disttae and `make -j8 build` passed. Native artifacts were built through the platform-aware `make cgo` owner, with verified source provenance. - Existing `vector_index_plugin_smoke.sql` ran in normal mo-tester comparison mode on a fresh, test-owned standalone service after SQL and ISCP readiness: **22/22 twice**, 0.262 s and 0.192 s. It validates HNSW/IVF creation, catalog metadata, SHOW CREATE, search, and rejection with the feature disabled. Database and table catalog residue were both zero after each run. No SQL/result files or mo-tester changes. An initial absolute dotted temporary-path invocation failed result-file discovery and executed no SQL; it is not counted as BVT evidence. - Rebased from `0b195e4f5a` to `62770aedaa` (only frontend clone/lineage locking and its tests changed upstream). Disttae and lockop suites were rerun after rebase; race/benchmark/IVF evidence is reused because those exercised paths and native inputs are unchanged. ### Review Self-review plus an independent read-only counterexample/ownership audit found no production blocker. Verified permit ownership across data/tombstone phases, no nested semaphore acquisition, and no reverse lock edge through tombstone I/O. No wire, persisted catalog format, configuration, or index implementation changes. The existing `PKPersistedBetween` process-context contract is unchanged; arbitrary contexts differing from `tbl.proc.Ctx` are not newly promised. | Audit | Ownership / termination | |---|---| | Q1: cleanup | Per-block readers release buffers; deferred scan permit release; test-owned FS/process cleanup and zero mpool residue | | Q2: waits | Non-nested semaphore admission observes context; readers receive that context; cancellation needs no metadata lock or semaphore permit | | Q3: growth | Existing 16-permit block-I/O admission; sequential block lifetime; no new queue, worker, retry state, or diagnostic cardinality; selected-object metadata remains snapshot-proportional | Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23844
What this PR does / why we need it:
HasTombstoneChanged is a table-level check that returns true if ANY tombstone object changed, causing false "txn need retry" errors during long-running IVF index builds. This PR replaces it with PK-aware tombstone checking: read PK column from changed tombstone objects and do exact match. Also fixes a varchar bug in LinearSearchOffsetByValFactory where the search closure compared keys against themselves instead of the target vector.