Skip to content

[Bug]: TestDispatchEmptyInputWaitsForRemoteReceiver flaky — dispatch returns before remote receiver attaches #25729

Closed

Description

@matrix-meow

Problem

TestDispatchEmptyInputWaitsForRemoteReceiver in pkg/sql/colexec/dispatch/dispatch_test.go:336 fails intermittently:

dispatch_test.go:336: empty dispatch returned before its remote receiver attached

The test verifies that the dispatch operator waits for a remote receiver to attach before returning when input is empty. The dispatch returns prematurely (before receiver attachment), indicating a race condition in the wait logic.

Recent Occurrences

Date PR/Run Job
2026-07-14 PR #25728 UT Test on Ubuntu/x86

Root Cause

Race condition between dispatch returning and remote receiver attachment. Under CI runner scheduling variability, the dispatch goroutine may complete before the receiver goroutine attaches.

Suggested Fix

  1. Add synchronization (channel/WaitGroup) to ensure receiver attachment happens before dispatch checks
  2. Or increase the wait tolerance in the dispatch wait logic
  3. Or make the test deterministic by using explicit synchronization instead of timing

Activity

  1. self-assigned this
    on Jul 15, 2026
  2. added a commit that references this issue on Jul 17, 2026
  3. daviszhen commented on Jul 17, 2026

    @daviszhen
    Contributor

    fixed

  4. LeftHandCold commented on Jul 18, 2026

    @LeftHandCold
    Collaborator

    Rechecked against current main 1a14737. The originally reported post-send completion assertion is absent. The dispatch test now directly asserts the authoritative state: prepared is true and remoteReceivers contains one entry; both are possible only after Dispatch.Call receives the remote handoff.

    The removed completion signal was closed after an unbuffered channel send. Its receiver could therefore return and inspect the signal before the sending goroutine was rescheduled to close it. That was a test scheduling race, not evidence that Dispatch returned before attachment.

    The PR #25742 failure record was generated against a merge ref, but the reported old assertion does not exist in the current-main test source. No duplicate fix is proposed: #25820 already superseded this issue code and test path.

  5. ghost closed this as completedon Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions