Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/changes/unreleased/1676-park-test-parts-race.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
kind: fixed
title: the park test waits for both parts to start instead of counting them at the park
pr: 1676
surface: [engine]
invalidates: []
---

TestAParentHandedADivisionBeforeItStartedOpensOnTheReportsAndNotOnTheWait counted
the parts its runner had seen at the moment the parent parked. A part reaches that
runner on a goroutine of its own, and the parent parks on the parts it has
outstanding rather than on their runners having started, so on a loaded CI box the
park came first and the test read one part. It now waits, bounded, for both.
18 changes: 12 additions & 6 deletions internal/session/task_park_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,18 @@ func TestAParentHandedADivisionBeforeItStartedOpensOnTheReportsAndNotOnTheWait(t
// One at a time, each landed only once the parent is back on its park, so the
// last report is the one that wakes it and every earlier one is already
// counted when it does.
partsMu.Lock()
landing := append([]*TaskNode(nil), parts...)
partsMu.Unlock()
if len(landing) != 2 {
t.Fatalf("%d parts were admitted, want the two that were proposed", len(landing))
}
//
// BOTH PARTS ARE WAITED FOR, NOT COUNTED AT THE PARK. A part reaches this
// test's runner on a goroutine of its own ([TaskGraph.runFrontier]), and the
// parent parks on the parts it has outstanding, not on their runners having
// started; on a loaded machine the park came first and CI read one part.
var landing []*TaskNode
waitFor(t, "both proposed parts to start", func() bool {
partsMu.Lock()
defer partsMu.Unlock()
landing = append(landing[:0], parts...)
return len(landing) == 2
})
for index, part := range landing {
if index > 0 {
// Past the park the previous landing was made against, so this one
Expand Down
Loading