stacklok / stacklok/mecatl

Flaky test: lifetime-pipe watcher may not observe Close on Linux

Open Beginner friendly
#1,683 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

flake
Dominant language
Go
Stars
152
Forks
16
Avg merge
14h 48m
Merged PRs (30d)
536

Description

Bug description

The root-b race shard intermittently fails in TestSDKServerEnablers_Scenario8_LifetimePipeIsQuietOnCleanShutdown after waiting 10 seconds for the lifetime-pipe watcher to observe p.Close().

Observed failures:

Both fail with:

--- FAIL: TestSDKServerEnablers_Scenario8_LifetimePipeIsQuietOnCleanShutdown (10.00s)
    daemonhosting_test.go:959: the watcher did not observe its own Close within 10s

No race-detector report is present.

Steps to reproduce

Run the root-b race shard repeatedly on Linux:

task test:race-root-b

The scheduling-sensitive sequence is:

  1. openLifetimePipe wraps a blocking inherited pipe descriptor with os.NewFile and starts watch.
  2. watch may enter a blocking Read while the writer remains open.
  3. The test calls p.Close() and waits for p.Closed().

On Linux, closing the descriptor from another goroutine does not guarantee that an already-blocked read wakes. If Close wins before Read, the test passes; if Read wins, it can remain blocked until the writer closes.

Expected behavior

The test should verify that clean shutdown does not emit lifetime pipe read failed without requiring an unsupported join guarantee from lifetimePipe.Close.

Actual behavior

The test asserts that Close wakes and joins the watcher within 10 seconds. This contradicts both the implementation comment and ADR 0027 List 1 row 66, which explicitly state that Close does not join the watcher and that it exits when the parent endpoint reaches EOF.

Environment

  • OS/version: GitHub-hosted Ubuntu 24.04 runners
  • Go: 1.27.x with -race
  • Deployment shape: cmd/mecated unit test in the root-b race shard

Suggested fix

Align the fixture with the documented lifecycle: call p.Close(), close the writer to release any in-flight Linux read, then wait for p.Closed() before checking the captured logs. Increasing the timeout alone will retain the race.

Tracked alongside #815 because both surfaced in the race shards, but the causes and fixes are independent.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with daemonhosting_test.go and TestSDKServerEnablers_Scenario8_LifetimePipeIsQuietOnCleanShutdown. Run task test:race-root-b repeatedly on Linux, then inspect the lifetime-pipe fixture and its Close/Closed sequence. Align the test with the documented lifecycle by releasing the writer before waiting for Closed, and verify clean shutdown does not log lifetime pipe read failed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.