[Flaky test] TestBackgroundWorktreeIsolationAndMerge

Aperta
#4,922 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@TDnorthgarden ci sta già lavorando.

Dal 13/11/2026.

  • #4923 di @TDnorthgarden — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
git, go
Ambito
backend, testing

Direzione di ricerca

Start with the concurrent launch in pkg/runtime/background_worktree_test.go (lines 134-139) and the completed assertion at line 156, then find where the background agent path runs git worktree add. Run the repro loop from the issue to see the commondir failure. Done means the flaky subtest passes reliably, either by serializing per-repo creation or retrying transient failures. PR #4923 is already open against this, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/runtime area/testing
Description

Failed once on PR #4907's test-linux (run 43133474124, first attempt, Nov 12). The linked=false subtest launches two background agents that create their git worktrees concurrently in the same repo (pkg/runtime/background_worktree_test.go:134-139); task first failed with

creating background worktree: creating git worktree: exit status 128:
Preparing worktree (new branch 'worktree-agent-bb8bc299-...')
fatal: failed to read .git/worktrees/agent-788eb22e-.../commondir: Success

while task second completed normally — its worktree is exactly the admin entry first's git worktree add stumbled on. A short read of a half-written commondir (errno 0 ⇒ "Success") means one git worktree add read another's in-flight administrative entry and exited 128, so the task was marked failed and the test's completed assertion (background_worktree_test.go:156) failed.

I reproduced the git-level race locally (linux/amd64, git 2.51.0), independently of the test harness: 16 concurrent git worktree add in a fresh repo, 400 rounds — 51 rounds hit exactly this error (fatal: failed to read .git/worktrees/<name>/commondir: Success, plus an ENOENT variant), with several concurrent adds stumbling over the same half-written entry within one round. The test itself only races 2 concurrent adds, which matches its low flake rate; CI runner I/O widens the window.

Expected Behavior

Concurrent background worktree creation in one repo is safe; a transient git failure of this kind doesn't fail a task the test expects to complete.

Actual Behavior

Intermittently, one concurrent creation fails on a half-written admin entry and the task is recorded as failed.

Steps to Reproduce
  1. Run the repro script (pasted under Error output) on Linux
  2. It races 16 concurrent git worktree add in a fresh repo, 400 rounds
  3. Measured here: 51/400 rounds hit the error below
Docker Agent version

No response

OS & terminal

No response

Model used

No response

Error output
hits=0
for r in $(seq 1 400); do
base=$(mktemp -d)
git init -q $base/repo
git -C $base/repo commit -q --allow-empty -m i
for i in $(seq 1 16); do
  ( git -C $base/repo worktree add $base/w$i HEAD >/dev/null 2>$base/err$i ) &
done
wait 
grep -q commondir $base/err* 2>/dev/null && hits=$((hits+1)) 
rm -rf $base 
done 
echo "rounds with a commondir failure: $hits/400"   # measured: 51/400
Screenshots

No response

Additional context

report-main-failures only auto-files flakes seen on main, so this PR-run failure isn't in the tracker yet. Suggested direction:
serialize per-repo worktree creation in the background-agent path, or retry a creation that fails with a transient commondir read error.
Happy to work on the fix.

Lingua principale
Go
Stelle
4.7k
Fork
565
Merge medio
18h 52m
PR unite (30g)
221

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di docker/docker-agent

Tutte le issue di docker/docker-agent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.