Skip to content

TestConnectPluginReady_HonorsACallerCancellation is RED under -race: a caller cancel waits out the 30s ReadyTimeout, and CI runs no race gate #1028

Open

Description

@aitrawog

The finding

TestConnectPluginReady_HonorsACallerCancellation (charly/plugin_connect_deadline_test.go:111-135, one of the charly#588 gates) is RED under go test -race and GREEN without it. The test cancels the caller's context at 300 ms and asserts the readiness read aborts within 10 s; under -race the call takes ~32 s — i.e. it returns at the test's own ReadyTimeout: 30 * time.Second, not at the cancel.

It reproduces on origin/main 9fd74793 with an OLD plugin-check pin and on the feat/plugin-check-2128-pin branch with the NEW pin, on a tree whose Go source is byte-identical between them (charly/go.mod + charly/go.sum only). So the pin is not the cause.

RCA

  • Mechanism (measured). Under -race, the caller's cancellation does not abort the in-flight readiness read promptly; the call returns after ~32 s, which tracks the test's 30 s ReadyTimeout rather than the 300 ms cancel. The returned error is a caller-cancellation error, not the readiness-bound error (the test's second assertion, which forbids did not become ready within, does not fire — see the logs: only the elapsed assertion fails). Two candidate legs remain un-isolated and are the follow-up's first task: (a) the go-plugin handshake (client.Client(), which takes no context) versus (b) the gRPC Describe in describeBounded (plugin_grpc.go:333) ignoring the cancelled rctx under the race detector. The handshake leg is bounded by loadedReadiness().PerAttempt, whose fallback is 120 s (spec/poll/poll.go:266), so the observed ~32 s is NOT the handshake bound — the wait is in, or the cancel surfaces only at the end of, the readiness leg.
  • Missed control. .github/workflows/ci.yml runs go test ./charly/... with no -race flag, so this class is invisible to the repository's own gate; it was found only by an ad-hoc -race run during consumer pin work.
  • Blast radius. The LocalTransport.Connect(ctx) cancellation contract, and therefore the charly#588 cancellation gate. Production connect sites deliberately pass context.Background() (plugin_connect_deadline.go:105-112), so no production run hangs today; any future caller that relies on cancelling a connect inherits the ~30 s delay. The non-race suite used by CI is unaffected.
  • Root fix. Isolate which leg swallows the cancel, then honour the caller's context there (for the handshake: run client.Client() under a select on ctx.Done() and tear down bounded; for the describe leg: make describeBounded return on a cancelled rctx rather than at the ReadyTimeout). Then the test must pass under -race.

Evidence (run on a fresh worktree)

Trees: origin/main = 9fd74793, tree be0eb882e33a481f2ed1f660abfdfea2d41439e5; branch head fa0382b5, tree ca520dc07e75460cee69723299c85ebf8706e162 (charly/go.mod +1/−1, charly/go.sum +2/−2).

# origin/main (old pin), -race, the single test
--- FAIL: TestConnectPluginReady_HonorsACallerCancellation (33.94s)
    plugin_connect_deadline_test.go:130: cancellation took 33.94319068s to abort the readiness read; the caller's context must propagate
FAIL	github.com/opencharly/charly/charly	66.353s

# branch head (new pin), -race, the single test (inside the full package run)
--- FAIL: TestConnectPluginReady_HonorsACallerCancellation (31.84s)
    plugin_connect_deadline_test.go:130: cancellation took 31.840173975s to abort the readiness read; the caller's context must propagate
FAIL	github.com/opencharly/charly/charly	871.328s

# branch head, same test, NO -race
--- PASS: TestConnectPluginReady_HonorsACallerCancellation (4.46s)
ok  	github.com/opencharly/charly/charly	8.596s

# branch head, the repo's own configured CI step (no -race)
ok  	github.com/opencharly/charly/charly	481.711s
ok  	github.com/opencharly/charly/charly/internal/pluginsgen	131.100s

A first -race run on the branch used GOTMPDIR=$HOME/.cache/go-tmp and produced the same failure (37.09 s) plus a go-plugin socket/handshake warning; re-running with CI's own TMPDIR=/tmp/charly-ci GOTMPDIR=/tmp/charly-ci (/tmp/charly-ci/... paths, well inside the 107-byte sun_path cap) reproduced the failure, so the temp-dir length is a separate, non-causal variable.

Agent: containerd-crabbox-program/charlypin · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

Activity

  1. added
    category:governance
    type:fix
    on Nov 23, 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

    category:governancetype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions