Skip to content

[4.2-dev] Isolate shared metadata cancellation and correct cleanup diagnostics - #32905

Merged
XuPeng-SH merged 4 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/32389-42-sampling-cancel
Nov 18, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/32389-42-sampling-cancel

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #32389. Backports the metadata cancellation fix from #29779.

What this PR does / why we need it:

When parallel readers share a metadata or Bloom filter load, a normal pipeline stop can cancel the load owner. A waiter whose own context is still live used to receive that owner's cancellation as its read result. This can interrupt or underfill an IVF training sample.

The existing cache coordination now lets a live waiter take over after the owner returns a cancellation attributable to its context. Each caller can issue at most one load under its own context, with at most one active owner per key. Real I/O errors, mixed errors, and the waiter's own cancellation or deadline retain their semantics. Cache hits bypass load coordination.

Scope cancellation that survives classification gets a structured event before cleanup changes context state. It records the phase, original and returned errors, observed context causes, and trace or transaction correlation.

  • Bare cancellation or deadline matching the reader's own context is a bounded DEBUG event. Unattributed, mixed, and actual storage failures remain visible at ERROR. A normal stop while building parallel readers is DEBUG and still contributes to its existing counter.
  • Typed terminal sends do not wait for channel capacity. Connector, dispatch, and remote notification report an unqueued terminal as DEBUG when the edge already holds a durable terminal state. A missing channel or still-active edge remains WARN. Existing cleanup counters stay intact, and cleanup logs share the existing strict time budget.
  • An optional disk-cache write canceled by its caller is DEBUG and does not inflate the disk-cache error rate. Real write or cleanup failures remain WARN and count as errors.

The SQL results, terminal delivery and storage format stay the same. Cache hit behavior is unchanged. The cold metadata path adds one small group allocation and synchronizes admission and cleanup. A single-threaded coordination-only microbenchmark measured 481 to 533 ns/op, excluding object I/O.

Validation

  • Full race runs for pkg/objectio, pkg/sql/compile, and pkg/vm/engine/readutil. Retained cache ownership cases were also stress-tested under race. Cleanup owners and consumers were covered by the final race run.
  • Scope and reader log checks distinguish matching cancellation from failure while contexts are live. Disk-cache tests cover matching cancellation, deadline, mixed errors, and a real cleanup failure racing cancellation. Existing terminal delivery and event budget checks continue to pass under race.
  • Incremental gofmt, diff check, and golangci-lint passed. Any molint findings in the selected packages also occur on the base revision.
  • Earlier controlled SIFT1M runs demonstrated the shared-load defect and validated the cache-only correction. The first cancellation source of the historical TKE failures remains unconfirmed.
  • On the delivery code, a local three-CN cluster built an IVF index three times over 1M SIFT128 rows with vector_ip_ops lists=500, returned 10 rows from the normalized vector query each time, and dropped each index. The local launcher used an isolated proxy port. The INFO log contained no reader cancellation errors, false terminal timeout warnings, or disk-cache cancellation warnings during these builds.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · superseded

Commit: 8ae22a6633cab63b787872248d1df0df3c332635

PR closed or head changed

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner November 18, 2026 17:17
@XuPeng-SH XuPeng-SH changed the title [4.2-dev] Isolate shared metadata load cancellation and bound pipeline diagnostics [4.2-dev] Isolate shared metadata cancellation and correct cleanup diagnostics Nov 18, 2026
@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/L Denotes a PR that changes [500,999] lines labels Nov 18, 2026
@XuPeng-SH

XuPeng-SH commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: a62d78d9b322d00238104adb67bed8dd1a004880

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: a62d78d9b322d00238104adb67bed8dd1a004880

Assessment: request_changes

The metadata handoff reuses the existing cache coordinator, and terminal diagnostics use the edge’s durable state. The disk-cache change can suppress the warning and error count when cancellation coincides with a failed temporary-file removal.

Model: gpt-6.2-sol / xhigh

Session: 01a1eecd-3287-70c0-bb93-ab923faf5f3f · slot 0 · generation 2

  • P2 pkg/fileservice/disk_cache.go:503: The write returns its caller’s cancellation while removing the temporary file fails and cleanup of the final cache path succeeds.
    Impact: The temporary path remains on disk, but the write is treated as routine cancellation at DEBUG and the disk-cache error counter stays flat.
    Evidence: The defer at line 564 discards the removal error, so the new classifier sees cleanupErr as nil. A race-enabled probe forced the temporary-path removal to fail. The candidate left the path behind and recorded a counter delta of 0. The same probe with the merge-base disk_cache.go emitted a warning and recorded a delta of 1. Carry unexpected temporary-file removal errors into the cleanup diagnostic and cover that path in TestDiskCacheBadWrite.

Validation:

  • Isolation preflight, native build, and git diff --check passed. Receipts 1795023112560506024-5, 1795023168407401776-4, and 1795023399493559253-3.

  • Focused race tests passed for objectio, fileservice, process, compile, connector, and dispatch. Six metadata ownership and reader tests also passed 20 runs each under race. Logs focused-race.log and metadata-stress.log, receipts 1795023324951055135-3 and 1795023371924674713-3.

  • Full readutil and logutil race suites passed. Log reader-event-race.log, receipt 1795023362643657701-3.

  • The temporary-path probe failed on the candidate and passed with the merge-base disk_cache.go overlay. Logs disk-cache-unlink-probe.log and disk-cache-merge-base-probe.log, receipts 1795023326459057934-4 and 1795023373680242092-8.

Limitations:

  • The first cancellation in issue #32389 remains unidentified. The three-CN SIFT1M runs are author-reported, and this review did not repeat the historical TKE workload.

  • The frozen evidence references backport PR #29779 without including its contents.

@XuPeng-SH

XuPeng-SH commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: e1ccf5b1e86efd0bd49d3c31b3c05c4f1541c7d6

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: e1ccf5b1e86efd0bd49d3c31b3c05c4f1541c7d6

Assessment: approve

The metadata cache lets a live waiter take over a canceled load while keeping one active loader per key and preserving storage errors. Cleanup logging uses the existing edge state and shared rate limiter. The current head resolves the prior disk-cache finding by logging and counting a failed temporary-file removal even when the caller canceled.

Model: gpt-6.2-sol / xhigh

Session: 01a1ee7f-fdcb-7b83-ad57-3b17a0e9d494 · slot 1 · generation 1

Validation:

  • Frozen source and patch verification, gofmt, isolation preflight, and the native build passed. Receipts 1795025582288183800-2, 1795025914444286620-2, 1795025561993671169-2, and 1795025620773861819-2.

  • Full race runs passed for objectio, process, connector, and dispatch. A reviewer probe verified terminal log levels, rate limiting, and counter increments. Log terminal-metadata-race.log, receipt 1795025926351842868-2.

  • TestDiskCacheBadWrite passed 25 race-enabled repetitions. A separate run confirmed that the warning included the unlink error. Twenty disk-cache tests passed in the final selection, and TestDiskCacheDirSize passed in the broader run. Receipts 1795025790751521926-2, 1795025835776431137-2, 1795026009995789115-2, and 1795025869258657375-2.

  • Reused the prior same-PR race evidence for unchanged behavior, including focused SQL compile tests, full readutil and logutil tests, and 20 repetitions of six metadata handoff tests. Prior receipts 1795023324951055135-3, 1795023362643657701-3, and 1795023371924674713-3.

Limitations:

  • The full fileservice race run timed out during a LocalFS tree write with caching disabled. A separate disk-cache run hit its shorter time limit during fsync in TestDiskCacheDirSize, which had passed in the broader run. Logs fileservice-race.log and disk-cache-race.log, receipts 1795025869258657375-2 and 1795025954065567999-2.

  • The three-CN SIFT1M runs were author-reported. This review did not rerun the historical TKE workload, and the first cancellation in issue #32389 remains unidentified. The frozen evidence references backport PR #29779 without including its contents.

This branch was successfully deployed

No deployments
ci — d3bcddbb Deployed Nov 18, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants