Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…matrixorigin#28361) ## What type of PR is this? - [x] BUG - [x] Improvement ## Related changes Follow-up to matrixorigin#28359; related to matrixorigin#28357. The lost caller-context defect reproduces both on matrixorigin#28359 and its pre-PR base; it was not introduced by that PR's catalog-tombstone policy change. Final head: `725319c627ce358827ce54b31025c5d10df89e25`, base `main` at `074bc173a5b64ed0ff0b6ad6ab091f478bf76c27`. Preserves the earlier cancellation fix, length-rejection fix and concurrent SCA cleanup. ## Root cause and implementation ### Persisted PK checks must use the operation's context `PrimaryKeysMayBeModified` / `PrimaryKeysMayBeUpserted` accept a caller context, but `PKPersistedBetween` replaced it with the relation's transaction-process context. Internal SQL using an existing transaction can have a shorter statement deadline, so cancellation did not reach metadata/block reads or PK I/O admission. Pass caller context through the persisted boundary, metadata/BF reads, predicate construction, data/tombstone reads and permit admission. Observe cancellation between objects/blocks and at return: a synchronous or cache-backed read completing after cancellation cannot turn cancellation into successful validation or a metadata-conflict retry. The shared transaction process is not mutated. Actual PK conflicts, `(from, to]` commit-TS/abort filtering, conservative unknown/I/O outcomes, user-table cost guards, and the existing 16-permit admission policy remain unchanged. ### Exact unsorted membership should not repeatedly compare long common prefixes Tombstones are ordered by rowid, not their copied original PK; binary-searching the source would be incorrect. The previous unsorted varlen algorithm is O(rows × keys). Searching owned needles improves large misses, but full-tail byte binary search has two counterexamples: 1. Unequal lengths with long common prefixes lose equality's cheap length rejection. 2. Equal-length duplicate-heavy input concentrated just beyond the first eight keys regresses: with 4096 needles and a 2KB prefix, hot rank nine previously measured about 998 us versus linear's 289 us per 1024 rows. The final immutable descriptor keeps original byte ordering for sorted-source lookup and the first eight comparisons. Its tail is length-ordered, copying only slice headers when the original order is not length-monotone. Search rejects absent lengths before touching payloads, then: - compares a same-length group of at most eight keys directly; - keeps binary search for larger inline-key groups; - uses a once-built standard Go string map for larger out-of-line-key groups. Only eligible long groups pay for hashing. The threshold uses the existing `types.VarlenaInlineSize` representation boundary, not an issue-specific key size or table/index type. Pure exponential bracketing was measured and rejected because moving from rank nine to rank seventeen still regressed. Map keys share only the descriptor's already-cloned, immutable Go-heap payloads via the existing byte-to-string helper; no second payload copy or caller/cache-buffer retention. Maps are completely constructed before publication, never mutated by search, and may safely be shared by combined predicates. Transient source-byte string lookups do not allocate or retain source values. There is no per-block lookup construction, global cache, lazy initialization, new worker, lock, retry or timeout. Small-key, sorted-source, constant, prefix/range, NULL/unavailable-column and OID-mismatch semantics remain intact. No wire/storage/catalog formats, authorization rules, config, native code or generated files change. ## Performance and costs Darwin arm64 / Apple M4, Go 1.26.4. Same-process paired current/previous-linear benchmarks, median of three 100ms samples. These are component measurements, not SQL/TPCC/nightly throughput claims. 1024 flat source rows, 2048-byte common prefix, 4096 needles: | Hot byte-order rank | Previous linear | Final implementation | | --- | ---: | ---: | | 9 | 291 us | 288 us | | 10 | 324 us | 282 us | | 17 | 538 us | 313 us | | Cycle over 32 tail keys | 770 us | 302 us | The prior 998us regression is removed. The cycling case does not depend on consecutive-value memoization. Repeated original PKs across different rowids/versions are valid tombstone input; this is not the shape of an ordinary unique-PK data block. 8192 rows, short-key **in-range misses**: | Needles | Previous linear | Final implementation | | ---: | ---: | ---: | | 9 | 516 us | 168 us | | 64 | 3.23 ms | 0.331 ms | | 1024 | 48.3 ms | 0.645 ms | | 4096 | 181 ms | 0.766 ms | Miss scans allocate zero bytes. The 4096-key all-first-key control is 37.6us versus linear64.5us. Every measured length-shape variant (9/16/64 keys, 16/256/2048-byte prefixes, shorter/gap/present-length nonmembers plus actual hits) remains faster than its paired linear control. Construction is not free and can be paid even if subsequent blocks are sorted or constant: - Short single-key descriptors remain 168B/4 allocations; 4096 equal-length short keys remain 163968B/4099 allocations. Mixed short keys needing a secondary order use 262304B/4101 allocations; the existing auxiliary holder grows by eight bytes. - A 4096-key, 2KB-prefix constructor totals about 1.47ms/9.75MB for equal lengths or 5.18ms/9.85MB for mixed lengths, including original payload cloning and sorting. Its once-built hash metadata is roughly 0.21MiB for 4096 entries, not another 8MiB payload copy. - No claim of universal improvement on every input or platform. Machine-load variation is visible in controls; the original nightly workload has not been rerun. Selected history still determines total scan work. The permit limit bounds concurrent block readers, not total metadata/history. Cancellation remains cooperative for synchronous CPU work and third-party readers that ignore context. ## Validation Final source, before committing without further code edits: - Focused `TestReadFilterExact*`: PASS, 0.547s. Complete offset oracles cover VARCHAR/VARBINARY, empty/duplicate/arbitrary bytes, all key positions, unequal-length gaps, sparse mixed small/large groups, original-buffer mutation, sorted/unsorted and combined predicates, and real sealed cache-backed vectors without full-column cloning. - Explicit group-size and inline/out-of-line boundary tests cover 16/17 total keys and `VarlenaInlineSize` / `VarlenaInlineSize+1`. - New concurrent reuse test: four private source vectors share one immutable combined hash-backed descriptor after caller buffers are overwritten; exact offsets and misses verified. `-race -count=100` PASS, 1.568s. - Final normal owning/consumer packages: objectio2.781s, objectio/ioutil1.032s, readutil2.126s, disttae9.010s. All four pass `go vet`. - Final owning race suites: objectio6.644s, disttae12.056s. - Final complete Search/KeyLengths/Construction/HotRanks benchmark matrix: PASS, 74.354s. Functional offsets are checked independently before timing the added hotspots. - Native-aware tests verify matching native-source/platform provenance and use the supported linked-test runtime loading setup. `gofmt -s` and `git diff --check` are clean. Retained evidence for unchanged cancellation behavior: - The same deterministic public-entry probe fails before the fix and passes after it: caller/reader/returned errors all reflect `context.Canceled`, with the transaction parent still alive. - One-row actual persisted fixtures cover VARCHAR/BIGINT data and tombstones, Modified/Upserted callers, metadata cancellation, cancellation after admission, completing non-cooperative reads, full-permit waits, release and healthy reuse detecting real conflicts. No sleeps or cluster startup. - The existing real 50001-row tombstone fixture retains catalog/user-table policy, last-block conflict and commit-time boundary oracles, with multi-key coverage and no extra heavy fixture. - Three earlier named cancellation/admission tests have 100-repetition race evidence; their synchronization is unchanged, and the final disttae owning race suite exercises them again. - Earlier lockop checks and full native-aware mo-service build passed. Before these internal algorithm follow-ups, real-service `vector_index_plugin_smoke.sql` passed 22/22 twice in normal comparison mode on one clean-start instance; teardown left no database/table/index residue and the owned service was stopped. This historical SQL smoke is not claimed as rerun on the latest hash implementation. Final encoded-cache and real persisted-object tests validate the changed internal boundary without another cluster-heavy fixture. ## QA test plan 1. Use `.agents/skills/mo-dev/scripts/mo-cgo-test` to run `TestReadFilterExact*`, the persisted caller-context tests, and the related owning/consumer packages. Run objectio/disttae under race and exact concurrent-reuse/cancellation tests individually under stress. 2. Run `BenchmarkReadFilterExactSearch`, `BenchmarkReadFilterExactKeyLengths`, `BenchmarkReadFilterExactHotRanks` and `BenchmarkReadFilterExactConstruction` with allocations. Compare paired current/linear runs; include different hotspot ranks, cycling keys, length gaps, same-length misses, small/large groups and short/long construction. Do not add wall-clock thresholds to ordinary UT. 3. Run `BenchmarkCatalogTombstoneMultiKeyCheck` separately for actual persisted-object integration cost. 4. For public smoke, start a test-owned service and wait for SQL readiness plus `ISCP-Task Start`; run the vector index plugin smoke with normal mo-tester comparison, verify teardown, and repeat on the same instance. 5. In the original nightly/remote-storage environment, verify unrelated catalog history does not restart the whole DDL, genuine concurrent catalog changes still cause safe retry, and cancelled internal SQL stops its persisted check. Measure complete index-build phases separately from component benchmarks. No CI wait or claim that the full CI matrix has passed.
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…matrixorigin#28361) ## What type of PR is this? - [x] BUG - [x] Improvement ## Related changes Follow-up to matrixorigin#28359; related to matrixorigin#28357. The lost caller-context defect reproduces both on matrixorigin#28359 and its pre-PR base; it was not introduced by that PR's catalog-tombstone policy change. Final head: `725319c627ce358827ce54b31025c5d10df89e25`, base `main` at `074bc173a5b64ed0ff0b6ad6ab091f478bf76c27`. Preserves the earlier cancellation fix, length-rejection fix and concurrent SCA cleanup. ## Root cause and implementation ### Persisted PK checks must use the operation's context `PrimaryKeysMayBeModified` / `PrimaryKeysMayBeUpserted` accept a caller context, but `PKPersistedBetween` replaced it with the relation's transaction-process context. Internal SQL using an existing transaction can have a shorter statement deadline, so cancellation did not reach metadata/block reads or PK I/O admission. Pass caller context through the persisted boundary, metadata/BF reads, predicate construction, data/tombstone reads and permit admission. Observe cancellation between objects/blocks and at return: a synchronous or cache-backed read completing after cancellation cannot turn cancellation into successful validation or a metadata-conflict retry. The shared transaction process is not mutated. Actual PK conflicts, `(from, to]` commit-TS/abort filtering, conservative unknown/I/O outcomes, user-table cost guards, and the existing 16-permit admission policy remain unchanged. ### Exact unsorted membership should not repeatedly compare long common prefixes Tombstones are ordered by rowid, not their copied original PK; binary-searching the source would be incorrect. The previous unsorted varlen algorithm is O(rows × keys). Searching owned needles improves large misses, but full-tail byte binary search has two counterexamples: 1. Unequal lengths with long common prefixes lose equality's cheap length rejection. 2. Equal-length duplicate-heavy input concentrated just beyond the first eight keys regresses: with 4096 needles and a 2KB prefix, hot rank nine previously measured about 998 us versus linear's 289 us per 1024 rows. The final immutable descriptor keeps original byte ordering for sorted-source lookup and the first eight comparisons. Its tail is length-ordered, copying only slice headers when the original order is not length-monotone. Search rejects absent lengths before touching payloads, then: - compares a same-length group of at most eight keys directly; - keeps binary search for larger inline-key groups; - uses a once-built standard Go string map for larger out-of-line-key groups. Only eligible long groups pay for hashing. The threshold uses the existing `types.VarlenaInlineSize` representation boundary, not an issue-specific key size or table/index type. Pure exponential bracketing was measured and rejected because moving from rank nine to rank seventeen still regressed. Map keys share only the descriptor's already-cloned, immutable Go-heap payloads via the existing byte-to-string helper; no second payload copy or caller/cache-buffer retention. Maps are completely constructed before publication, never mutated by search, and may safely be shared by combined predicates. Transient source-byte string lookups do not allocate or retain source values. There is no per-block lookup construction, global cache, lazy initialization, new worker, lock, retry or timeout. Small-key, sorted-source, constant, prefix/range, NULL/unavailable-column and OID-mismatch semantics remain intact. No wire/storage/catalog formats, authorization rules, config, native code or generated files change. ## Performance and costs Darwin arm64 / Apple M4, Go 1.26.4. Same-process paired current/previous-linear benchmarks, median of three 100ms samples. These are component measurements, not SQL/TPCC/nightly throughput claims. 1024 flat source rows, 2048-byte common prefix, 4096 needles: | Hot byte-order rank | Previous linear | Final implementation | | --- | ---: | ---: | | 9 | 291 us | 288 us | | 10 | 324 us | 282 us | | 17 | 538 us | 313 us | | Cycle over 32 tail keys | 770 us | 302 us | The prior 998us regression is removed. The cycling case does not depend on consecutive-value memoization. Repeated original PKs across different rowids/versions are valid tombstone input; this is not the shape of an ordinary unique-PK data block. 8192 rows, short-key **in-range misses**: | Needles | Previous linear | Final implementation | | ---: | ---: | ---: | | 9 | 516 us | 168 us | | 64 | 3.23 ms | 0.331 ms | | 1024 | 48.3 ms | 0.645 ms | | 4096 | 181 ms | 0.766 ms | Miss scans allocate zero bytes. The 4096-key all-first-key control is 37.6us versus linear64.5us. Every measured length-shape variant (9/16/64 keys, 16/256/2048-byte prefixes, shorter/gap/present-length nonmembers plus actual hits) remains faster than its paired linear control. Construction is not free and can be paid even if subsequent blocks are sorted or constant: - Short single-key descriptors remain 168B/4 allocations; 4096 equal-length short keys remain 163968B/4099 allocations. Mixed short keys needing a secondary order use 262304B/4101 allocations; the existing auxiliary holder grows by eight bytes. - A 4096-key, 2KB-prefix constructor totals about 1.47ms/9.75MB for equal lengths or 5.18ms/9.85MB for mixed lengths, including original payload cloning and sorting. Its once-built hash metadata is roughly 0.21MiB for 4096 entries, not another 8MiB payload copy. - No claim of universal improvement on every input or platform. Machine-load variation is visible in controls; the original nightly workload has not been rerun. Selected history still determines total scan work. The permit limit bounds concurrent block readers, not total metadata/history. Cancellation remains cooperative for synchronous CPU work and third-party readers that ignore context. ## Validation Final source, before committing without further code edits: - Focused `TestReadFilterExact*`: PASS, 0.547s. Complete offset oracles cover VARCHAR/VARBINARY, empty/duplicate/arbitrary bytes, all key positions, unequal-length gaps, sparse mixed small/large groups, original-buffer mutation, sorted/unsorted and combined predicates, and real sealed cache-backed vectors without full-column cloning. - Explicit group-size and inline/out-of-line boundary tests cover 16/17 total keys and `VarlenaInlineSize` / `VarlenaInlineSize+1`. - New concurrent reuse test: four private source vectors share one immutable combined hash-backed descriptor after caller buffers are overwritten; exact offsets and misses verified. `-race -count=100` PASS, 1.568s. - Final normal owning/consumer packages: objectio2.781s, objectio/ioutil1.032s, readutil2.126s, disttae9.010s. All four pass `go vet`. - Final owning race suites: objectio6.644s, disttae12.056s. - Final complete Search/KeyLengths/Construction/HotRanks benchmark matrix: PASS, 74.354s. Functional offsets are checked independently before timing the added hotspots. - Native-aware tests verify matching native-source/platform provenance and use the supported linked-test runtime loading setup. `gofmt -s` and `git diff --check` are clean. Retained evidence for unchanged cancellation behavior: - The same deterministic public-entry probe fails before the fix and passes after it: caller/reader/returned errors all reflect `context.Canceled`, with the transaction parent still alive. - One-row actual persisted fixtures cover VARCHAR/BIGINT data and tombstones, Modified/Upserted callers, metadata cancellation, cancellation after admission, completing non-cooperative reads, full-permit waits, release and healthy reuse detecting real conflicts. No sleeps or cluster startup. - The existing real 50001-row tombstone fixture retains catalog/user-table policy, last-block conflict and commit-time boundary oracles, with multi-key coverage and no extra heavy fixture. - Three earlier named cancellation/admission tests have 100-repetition race evidence; their synchronization is unchanged, and the final disttae owning race suite exercises them again. - Earlier lockop checks and full native-aware mo-service build passed. Before these internal algorithm follow-ups, real-service `vector_index_plugin_smoke.sql` passed 22/22 twice in normal comparison mode on one clean-start instance; teardown left no database/table/index residue and the owned service was stopped. This historical SQL smoke is not claimed as rerun on the latest hash implementation. Final encoded-cache and real persisted-object tests validate the changed internal boundary without another cluster-heavy fixture. ## QA test plan 1. Use `.agents/skills/mo-dev/scripts/mo-cgo-test` to run `TestReadFilterExact*`, the persisted caller-context tests, and the related owning/consumer packages. Run objectio/disttae under race and exact concurrent-reuse/cancellation tests individually under stress. 2. Run `BenchmarkReadFilterExactSearch`, `BenchmarkReadFilterExactKeyLengths`, `BenchmarkReadFilterExactHotRanks` and `BenchmarkReadFilterExactConstruction` with allocations. Compare paired current/linear runs; include different hotspot ranks, cycling keys, length gaps, same-length misses, small/large groups and short/long construction. Do not add wall-clock thresholds to ordinary UT. 3. Run `BenchmarkCatalogTombstoneMultiKeyCheck` separately for actual persisted-object integration cost. 4. For public smoke, start a test-owned service and wait for SQL readiness plus `ISCP-Task Start`; run the vector index plugin smoke with normal mo-tester comparison, verify teardown, and repeat on the same instance. 5. In the original nightly/remote-storage environment, verify unrelated catalog history does not restart the whole DDL, genuine concurrent catalog changes still cause safe retry, and cancelled internal SQL stops its persisted check. Measure complete index-build phases separately from component benchmarks. No CI wait or claim that the full CI matrix has passed.
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…matrixorigin#28361) ## What type of PR is this? - [x] BUG - [x] Improvement ## Related changes Follow-up to matrixorigin#28359; related to matrixorigin#28357. The lost caller-context defect reproduces both on matrixorigin#28359 and its pre-PR base; it was not introduced by that PR's catalog-tombstone policy change. Final head: `725319c627ce358827ce54b31025c5d10df89e25`, base `main` at `074bc173a5b64ed0ff0b6ad6ab091f478bf76c27`. Preserves the earlier cancellation fix, length-rejection fix and concurrent SCA cleanup. ## Root cause and implementation ### Persisted PK checks must use the operation's context `PrimaryKeysMayBeModified` / `PrimaryKeysMayBeUpserted` accept a caller context, but `PKPersistedBetween` replaced it with the relation's transaction-process context. Internal SQL using an existing transaction can have a shorter statement deadline, so cancellation did not reach metadata/block reads or PK I/O admission. Pass caller context through the persisted boundary, metadata/BF reads, predicate construction, data/tombstone reads and permit admission. Observe cancellation between objects/blocks and at return: a synchronous or cache-backed read completing after cancellation cannot turn cancellation into successful validation or a metadata-conflict retry. The shared transaction process is not mutated. Actual PK conflicts, `(from, to]` commit-TS/abort filtering, conservative unknown/I/O outcomes, user-table cost guards, and the existing 16-permit admission policy remain unchanged. ### Exact unsorted membership should not repeatedly compare long common prefixes Tombstones are ordered by rowid, not their copied original PK; binary-searching the source would be incorrect. The previous unsorted varlen algorithm is O(rows × keys). Searching owned needles improves large misses, but full-tail byte binary search has two counterexamples: 1. Unequal lengths with long common prefixes lose equality's cheap length rejection. 2. Equal-length duplicate-heavy input concentrated just beyond the first eight keys regresses: with 4096 needles and a 2KB prefix, hot rank nine previously measured about 998 us versus linear's 289 us per 1024 rows. The final immutable descriptor keeps original byte ordering for sorted-source lookup and the first eight comparisons. Its tail is length-ordered, copying only slice headers when the original order is not length-monotone. Search rejects absent lengths before touching payloads, then: - compares a same-length group of at most eight keys directly; - keeps binary search for larger inline-key groups; - uses a once-built standard Go string map for larger out-of-line-key groups. Only eligible long groups pay for hashing. The threshold uses the existing `types.VarlenaInlineSize` representation boundary, not an issue-specific key size or table/index type. Pure exponential bracketing was measured and rejected because moving from rank nine to rank seventeen still regressed. Map keys share only the descriptor's already-cloned, immutable Go-heap payloads via the existing byte-to-string helper; no second payload copy or caller/cache-buffer retention. Maps are completely constructed before publication, never mutated by search, and may safely be shared by combined predicates. Transient source-byte string lookups do not allocate or retain source values. There is no per-block lookup construction, global cache, lazy initialization, new worker, lock, retry or timeout. Small-key, sorted-source, constant, prefix/range, NULL/unavailable-column and OID-mismatch semantics remain intact. No wire/storage/catalog formats, authorization rules, config, native code or generated files change. ## Performance and costs Darwin arm64 / Apple M4, Go 1.26.4. Same-process paired current/previous-linear benchmarks, median of three 100ms samples. These are component measurements, not SQL/TPCC/nightly throughput claims. 1024 flat source rows, 2048-byte common prefix, 4096 needles: | Hot byte-order rank | Previous linear | Final implementation | | --- | ---: | ---: | | 9 | 291 us | 288 us | | 10 | 324 us | 282 us | | 17 | 538 us | 313 us | | Cycle over 32 tail keys | 770 us | 302 us | The prior 998us regression is removed. The cycling case does not depend on consecutive-value memoization. Repeated original PKs across different rowids/versions are valid tombstone input; this is not the shape of an ordinary unique-PK data block. 8192 rows, short-key **in-range misses**: | Needles | Previous linear | Final implementation | | ---: | ---: | ---: | | 9 | 516 us | 168 us | | 64 | 3.23 ms | 0.331 ms | | 1024 | 48.3 ms | 0.645 ms | | 4096 | 181 ms | 0.766 ms | Miss scans allocate zero bytes. The 4096-key all-first-key control is 37.6us versus linear64.5us. Every measured length-shape variant (9/16/64 keys, 16/256/2048-byte prefixes, shorter/gap/present-length nonmembers plus actual hits) remains faster than its paired linear control. Construction is not free and can be paid even if subsequent blocks are sorted or constant: - Short single-key descriptors remain 168B/4 allocations; 4096 equal-length short keys remain 163968B/4099 allocations. Mixed short keys needing a secondary order use 262304B/4101 allocations; the existing auxiliary holder grows by eight bytes. - A 4096-key, 2KB-prefix constructor totals about 1.47ms/9.75MB for equal lengths or 5.18ms/9.85MB for mixed lengths, including original payload cloning and sorting. Its once-built hash metadata is roughly 0.21MiB for 4096 entries, not another 8MiB payload copy. - No claim of universal improvement on every input or platform. Machine-load variation is visible in controls; the original nightly workload has not been rerun. Selected history still determines total scan work. The permit limit bounds concurrent block readers, not total metadata/history. Cancellation remains cooperative for synchronous CPU work and third-party readers that ignore context. ## Validation Final source, before committing without further code edits: - Focused `TestReadFilterExact*`: PASS, 0.547s. Complete offset oracles cover VARCHAR/VARBINARY, empty/duplicate/arbitrary bytes, all key positions, unequal-length gaps, sparse mixed small/large groups, original-buffer mutation, sorted/unsorted and combined predicates, and real sealed cache-backed vectors without full-column cloning. - Explicit group-size and inline/out-of-line boundary tests cover 16/17 total keys and `VarlenaInlineSize` / `VarlenaInlineSize+1`. - New concurrent reuse test: four private source vectors share one immutable combined hash-backed descriptor after caller buffers are overwritten; exact offsets and misses verified. `-race -count=100` PASS, 1.568s. - Final normal owning/consumer packages: objectio2.781s, objectio/ioutil1.032s, readutil2.126s, disttae9.010s. All four pass `go vet`. - Final owning race suites: objectio6.644s, disttae12.056s. - Final complete Search/KeyLengths/Construction/HotRanks benchmark matrix: PASS, 74.354s. Functional offsets are checked independently before timing the added hotspots. - Native-aware tests verify matching native-source/platform provenance and use the supported linked-test runtime loading setup. `gofmt -s` and `git diff --check` are clean. Retained evidence for unchanged cancellation behavior: - The same deterministic public-entry probe fails before the fix and passes after it: caller/reader/returned errors all reflect `context.Canceled`, with the transaction parent still alive. - One-row actual persisted fixtures cover VARCHAR/BIGINT data and tombstones, Modified/Upserted callers, metadata cancellation, cancellation after admission, completing non-cooperative reads, full-permit waits, release and healthy reuse detecting real conflicts. No sleeps or cluster startup. - The existing real 50001-row tombstone fixture retains catalog/user-table policy, last-block conflict and commit-time boundary oracles, with multi-key coverage and no extra heavy fixture. - Three earlier named cancellation/admission tests have 100-repetition race evidence; their synchronization is unchanged, and the final disttae owning race suite exercises them again. - Earlier lockop checks and full native-aware mo-service build passed. Before these internal algorithm follow-ups, real-service `vector_index_plugin_smoke.sql` passed 22/22 twice in normal comparison mode on one clean-start instance; teardown left no database/table/index residue and the owned service was stopped. This historical SQL smoke is not claimed as rerun on the latest hash implementation. Final encoded-cache and real persisted-object tests validate the changed internal boundary without another cluster-heavy fixture. ## QA test plan 1. Use `.agents/skills/mo-dev/scripts/mo-cgo-test` to run `TestReadFilterExact*`, the persisted caller-context tests, and the related owning/consumer packages. Run objectio/disttae under race and exact concurrent-reuse/cancellation tests individually under stress. 2. Run `BenchmarkReadFilterExactSearch`, `BenchmarkReadFilterExactKeyLengths`, `BenchmarkReadFilterExactHotRanks` and `BenchmarkReadFilterExactConstruction` with allocations. Compare paired current/linear runs; include different hotspot ranks, cycling keys, length gaps, same-length misses, small/large groups and short/long construction. Do not add wall-clock thresholds to ordinary UT. 3. Run `BenchmarkCatalogTombstoneMultiKeyCheck` separately for actual persisted-object integration cost. 4. For public smoke, start a test-owned service and wait for SQL readiness plus `ISCP-Task Start`; run the vector index plugin smoke with normal mo-tester comparison, verify teardown, and repeat on the same instance. 5. In the original nightly/remote-storage environment, verify unrelated catalog history does not restart the whole DDL, genuine concurrent catalog changes still cause safe retry, and cancelled internal SQL stops its persisted check. Measure complete index-build phases separately from component benchmarks. No CI wait or claim that the full CI matrix has passed.
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?
Related changes
Follow-up to #28359; related to #28357. The lost caller-context defect reproduces both on #28359 and its pre-PR base; it was not introduced by that PR's catalog-tombstone policy change.
Final head:
725319c627ce358827ce54b31025c5d10df89e25, basemainat074bc173a5b64ed0ff0b6ad6ab091f478bf76c27. Preserves the earlier cancellation fix, length-rejection fix and concurrent SCA cleanup.Root cause and implementation
Persisted PK checks must use the operation's context
PrimaryKeysMayBeModified/PrimaryKeysMayBeUpsertedaccept a caller context, butPKPersistedBetweenreplaced it with the relation's transaction-process context. Internal SQL using an existing transaction can have a shorter statement deadline, so cancellation did not reach metadata/block reads or PK I/O admission.Pass caller context through the persisted boundary, metadata/BF reads, predicate construction, data/tombstone reads and permit admission. Observe cancellation between objects/blocks and at return: a synchronous or cache-backed read completing after cancellation cannot turn cancellation into successful validation or a metadata-conflict retry. The shared transaction process is not mutated.
Actual PK conflicts,
(from, to]commit-TS/abort filtering, conservative unknown/I/O outcomes, user-table cost guards, and the existing 16-permit admission policy remain unchanged.Exact unsorted membership should not repeatedly compare long common prefixes
Tombstones are ordered by rowid, not their copied original PK; binary-searching the source would be incorrect. The previous unsorted varlen algorithm is O(rows × keys). Searching owned needles improves large misses, but full-tail byte binary search has two counterexamples:
The final immutable descriptor keeps original byte ordering for sorted-source lookup and the first eight comparisons. Its tail is length-ordered, copying only slice headers when the original order is not length-monotone. Search rejects absent lengths before touching payloads, then:
Only eligible long groups pay for hashing. The threshold uses the existing
types.VarlenaInlineSizerepresentation boundary, not an issue-specific key size or table/index type. Pure exponential bracketing was measured and rejected because moving from rank nine to rank seventeen still regressed.Map keys share only the descriptor's already-cloned, immutable Go-heap payloads via the existing byte-to-string helper; no second payload copy or caller/cache-buffer retention. Maps are completely constructed before publication, never mutated by search, and may safely be shared by combined predicates. Transient source-byte string lookups do not allocate or retain source values. There is no per-block lookup construction, global cache, lazy initialization, new worker, lock, retry or timeout.
Small-key, sorted-source, constant, prefix/range, NULL/unavailable-column and OID-mismatch semantics remain intact. No wire/storage/catalog formats, authorization rules, config, native code or generated files change.
Performance and costs
Darwin arm64 / Apple M4, Go 1.26.4. Same-process paired current/previous-linear benchmarks, median of three 100ms samples. These are component measurements, not SQL/TPCC/nightly throughput claims.
1024 flat source rows, 2048-byte common prefix, 4096 needles:
The prior 998us regression is removed. The cycling case does not depend on consecutive-value memoization. Repeated original PKs across different rowids/versions are valid tombstone input; this is not the shape of an ordinary unique-PK data block.
8192 rows, short-key in-range misses:
Miss scans allocate zero bytes. The 4096-key all-first-key control is 37.6us versus linear64.5us. Every measured length-shape variant (9/16/64 keys, 16/256/2048-byte prefixes, shorter/gap/present-length nonmembers plus actual hits) remains faster than its paired linear control.
Construction is not free and can be paid even if subsequent blocks are sorted or constant:
Selected history still determines total scan work. The permit limit bounds concurrent block readers, not total metadata/history. Cancellation remains cooperative for synchronous CPU work and third-party readers that ignore context.
Validation
Final source, before committing without further code edits:
TestReadFilterExact*: PASS, 0.547s. Complete offset oracles cover VARCHAR/VARBINARY, empty/duplicate/arbitrary bytes, all key positions, unequal-length gaps, sparse mixed small/large groups, original-buffer mutation, sorted/unsorted and combined predicates, and real sealed cache-backed vectors without full-column cloning.VarlenaInlineSize/VarlenaInlineSize+1.-race -count=100PASS, 1.568s.go vet.gofmt -sandgit diff --checkare clean.Retained evidence for unchanged cancellation behavior:
context.Canceled, with the transaction parent still alive.vector_index_plugin_smoke.sqlpassed 22/22 twice in normal comparison mode on one clean-start instance; teardown left no database/table/index residue and the owned service was stopped. This historical SQL smoke is not claimed as rerun on the latest hash implementation. Final encoded-cache and real persisted-object tests validate the changed internal boundary without another cluster-heavy fixture.QA test plan
.agents/skills/mo-dev/scripts/mo-cgo-testto runTestReadFilterExact*, the persisted caller-context tests, and the related owning/consumer packages. Run objectio/disttae under race and exact concurrent-reuse/cancellation tests individually under stress.BenchmarkReadFilterExactSearch,BenchmarkReadFilterExactKeyLengths,BenchmarkReadFilterExactHotRanksandBenchmarkReadFilterExactConstructionwith allocations. Compare paired current/linear runs; include different hotspot ranks, cycling keys, length gaps, same-length misses, small/large groups and short/long construction. Do not add wall-clock thresholds to ordinary UT.BenchmarkCatalogTombstoneMultiKeyCheckseparately for actual persisted-object integration cost.ISCP-Task Start; run the vector index plugin smoke with normal mo-tester comparison, verify teardown, and repeat on the same instance.No CI wait or claim that the full CI matrix has passed.