Skip to content

fix(pipeline): replace busy-wait polling with channel-based notification - #24269

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aunjgr:fix/remoterun-busy-wait
May 5, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aunjgr:fix/remoterun-busy-wait

Conversation

@aunjgr

@aunjgr aunjgr commented May 3, 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:

issue #23277
issue #23278
issue #23284

What this PR does / why we need it:

Replaces the runtime.Gosched() busy-wait polling loop in remoterunServer.GetProcByUuid with a proper channel-based notification mechanism.

Changes:

  • UuidProcMap gains a changed chan struct{} that is closed-and-swapped on every PutProcIntoUuidMap call, broadcasting to all waiters
  • New GetProcByUuidOrWait method atomically returns a wait channel on lookup miss, eliminating the TOCTOU race between lookup and wait
  • Removes HandleNotifyTimeout (3600s) from remoterunServer.go — the connection/query context is the natural lifetime bound
  • Removes waitNotifyTimeout (3600s) from dispatch/types.go — proc.Ctx already bounds waitRemoteRegsReady
  • Fixes NewServer init race with CompareAndSwap instead of check-then-set
  • Provides a meaningful cancellation cause ("remote receiver connection closed") instead of nil when connection drops

@aunjgr
aunjgr requested a review from ouyuanning as a code owner May 3, 2026 16:53
@qodo-code-review

Copy link
Copy Markdown
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

Replace the runtime.Gosched() busy-wait loop in GetProcByUuid with a
channel-based notification mechanism. PutProcIntoUuidMap now broadcasts
to waiters via a close-and-swap channel pattern, and GetProcByUuidOrWait
atomically returns a wait channel on lookup miss to avoid TOCTOU races.

Also removes the arbitrary 3600s HandleNotifyTimeout and waitNotifyTimeout
constants — query/connection context cancellation is the natural lifetime
bound. Fixes NewServer init race with CompareAndSwap, and provides a
meaningful cancellation cause when remote connection drops.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mergify mergify Bot added the queued label May 5, 2026
@mergify

mergify Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-05 05:35 UTC · Rule: main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-05-05 05:35 UTC · at 7201dabc85e8e16c5382438c0eec566afa9d166e · squash

This pull request spent 14 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

@mergify
mergify Bot merged commit 36016d5 into matrixorigin:main May 5, 2026
42 of 44 checks passed
@mergify mergify Bot removed the queued label May 5, 2026
@aunjgr
aunjgr deleted the fix/remoterun-busy-wait branch May 6, 2026 15:04
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
…ion (matrixorigin#24269)

Replaces the `runtime.Gosched()` busy-wait polling loop in `remoterunServer.GetProcByUuid` with a proper channel-based notification mechanism.

**Changes:**
- `UuidProcMap` gains a `changed chan struct{}` that is closed-and-swapped on every `PutProcIntoUuidMap` call, broadcasting to all waiters
- New `GetProcByUuidOrWait` method atomically returns a wait channel on lookup miss, eliminating the TOCTOU race between lookup and wait
- Removes `HandleNotifyTimeout` (3600s) from `remoterunServer.go` — the connection/query context is the natural lifetime bound
- Removes `waitNotifyTimeout` (3600s) from `dispatch/types.go` — `proc.Ctx` already bounds `waitRemoteRegsReady`
- Fixes `NewServer` init race with `CompareAndSwap` instead of check-then-set
- Provides a meaningful cancellation cause (`"remote receiver connection closed"`) instead of nil when connection drops

Approved by: @ouyuanning
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…ion (matrixorigin#24269)

Replaces the `runtime.Gosched()` busy-wait polling loop in `remoterunServer.GetProcByUuid` with a proper channel-based notification mechanism.

**Changes:**
- `UuidProcMap` gains a `changed chan struct{}` that is closed-and-swapped on every `PutProcIntoUuidMap` call, broadcasting to all waiters
- New `GetProcByUuidOrWait` method atomically returns a wait channel on lookup miss, eliminating the TOCTOU race between lookup and wait
- Removes `HandleNotifyTimeout` (3600s) from `remoterunServer.go` — the connection/query context is the natural lifetime bound
- Removes `waitNotifyTimeout` (3600s) from `dispatch/types.go` — `proc.Ctx` already bounds `waitRemoteRegsReady`
- Fixes `NewServer` init race with `CompareAndSwap` instead of check-then-set
- Provides a meaningful cancellation cause (`"remote receiver connection closed"`) instead of nil when connection drops

Approved by: @ouyuanning
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…ion (matrixorigin#24269)

Replaces the `runtime.Gosched()` busy-wait polling loop in `remoterunServer.GetProcByUuid` with a proper channel-based notification mechanism.

**Changes:**
- `UuidProcMap` gains a `changed chan struct{}` that is closed-and-swapped on every `PutProcIntoUuidMap` call, broadcasting to all waiters
- New `GetProcByUuidOrWait` method atomically returns a wait channel on lookup miss, eliminating the TOCTOU race between lookup and wait
- Removes `HandleNotifyTimeout` (3600s) from `remoterunServer.go` — the connection/query context is the natural lifetime bound
- Removes `waitNotifyTimeout` (3600s) from `dispatch/types.go` — `proc.Ctx` already bounds `waitRemoteRegsReady`
- Fixes `NewServer` init race with `CompareAndSwap` instead of check-then-set
- Provides a meaningful cancellation cause (`"remote receiver connection closed"`) instead of nil when connection drops

Approved by: @ouyuanning

This branch was previously deployed

1 inactive deployment
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 kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants