p5a: fix a deadlock in the given TestFetchIf (lock held across a request); run notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 21:45:57 -07:00
co-authored by Claude Opus 5.5
parent cfde35397a
commit 7fa5bd21b2
2 changed files with 11 additions and 4 deletions
+7 -1
View File
@@ -43,4 +43,10 @@ reaches orion until the owner's review, the merge, and straylight's pin bump.
## Changes during the run ## Changes during the run
(none yet) - 2026-09-25, task 01: **owner test fault.** `TestFetchIf` took its mutex with `defer mu.Unlock()`
and then made a third request, whose server handler needs that mutex: a deadlock that surfaced as
a 20 s upstream timeout. Ornith spent 55 minutes debugging it correctly (its notes had the
handler blocked on `mu.Lock` at the test line) and ended on a refused `/tmp` read, with the
implementation done but debug prints in `pdf.go` and a `zz_debug_test.go`. Owner fixed the test
(copy the slice under the lock, release before the next request), removed the debug scaffolding,
and resumed the session to finish and commit.
@@ -167,9 +167,10 @@ func TestFetchIf(t *testing.T) {
t.Fatalf("changed document: res %+v err %v; want 200 with the new body and ETag", res, err) t.Fatalf("changed document: res %+v err %v; want 200 with the new body and ETag", res, err)
} }
mu.Lock() mu.Lock()
defer mu.Unlock() sent := append([]string(nil), got...)
if len(got) != 2 || got[0] != `"v1"|` || got[1] != `"old"|Thu, 24 Sep 2026 12:00:00 GMT` { mu.Unlock() // never hold mu across another request: the handler takes it
t.Errorf("validators sent: %q", got) if len(sent) != 2 || sent[0] != `"v1"|` || sent[1] != `"old"|Thu, 24 Sep 2026 12:00:00 GMT` {
t.Errorf("validators sent: %q", sent)
} }
// With no validators FetchIf is a plain Fetch. // With no validators FetchIf is a plain Fetch.
if _, err := f.FetchIf(context.Background(), ts.URL, "", ""); err != nil { if _, err := f.FetchIf(context.Background(), ts.URL, "", ""); err != nil {