Skip to content

[Bug]: TestIndependentControlBackendPreservesSlowDataRequest races global idle GC #26649

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

Observed on PR head 1e72b8fc371475ed4db93d2e7600d33b6918ea0b; the failing MORPC test and client GC code are unchanged by that PR.

Other Environment Information

Actual Behavior

pkg/common/morpc.TestIndependentControlBackendPreservesSlowDataRequest intermittently loses its data backend before it deterministically drives the liveness-probe branch:

write request ... request-id=2
connection disconnected
read loop stopped
backend_test.go:734: Error: Should be true
Test: TestIndependentControlBackendPreservesSlowDataRequest

The test configures WithClientMaxBackendMaxIdleDuration(time.Nanosecond). The process-wide idle GC independently calls closeIdleBackends every second. Before keepDataConnectionAfterProbe marks the backend as draining, the backend remains admission-eligible, and its last-active timestamp exceeds the artificial 1 ns idle lifetime almost immediately. If a GC tick lands in that window, it detaches and closes the backend even though the first request is still outstanding. keepDataConnectionAfterProbe then observes a non-running backend and returns false at line 734.

This is a different race from #26184/#26189, which removed reliance on a real 4 ms socket timeout. The replacement test still races the global idle-GC ticker because of its 1 ns client idle lifetime.

Expected Behavior

The test should deterministically prove that idle GC preserves a draining backend with an outstanding request without allowing the process-wide GC loop to close the backend before the test establishes the draining state.

Steps to Reproduce

  1. Run the exact test normally under a loaded runner, particularly when it begins just before the process-wide one-second idle-GC tick:

    go test ./pkg/common/morpc -run '^TestIndependentControlBackendPreservesSlowDataRequest$' -count=200
  2. Accelerate the same production GC loop to reproduce the race locally:

    MORPC_GC_IDLE_INTERVAL=1ms go test ./pkg/common/morpc \
      -run '^TestIndependentControlBackendPreservesSlowDataRequest$' -count=20
  3. Observe the backend being removed/closed before the direct probe assertion. The accelerated run reproduces the exact backend_test.go:734: Should be true failure, as well as adjacent failures when GC wins earlier or later in the same lifecycle.

Additional information

  • A normal exact-test run with -count=200 passed locally, consistent with a narrow one-second ticker phase window.
  • The accelerated-GC run failed and logged the backend read/write loops stopping before the assertion.
  • client.closeIdleBackends protects a backend from idle closure only after admissionAvailable becomes false (draining). The test's 1 ns idle lifetime exposes it to global cleanup before keepDataConnectionAfterProbe performs that transition.
  • The failure is unrelated to PR test(gc): make deleter concurrency check deterministic #26644, whose GitHub diff changes only pkg/vm/engine/tae/db/gc/v3/deleter_test.go.

Activity

  1. self-assigned this
    on Aug 3, 2026
  2. added
    kind/bug
    severity/s0
    ai-easy
    and removed on Aug 3, 2026
  3. added 2 commits that reference this issue on Aug 3, 2026
    acfb8ef
    e601597
  4. added 6 commits that reference this issue on Sep 17, 2026
    411ec54
    7e4055a
    5a6a870
    3780d8f
    56b9403
    487409c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions