You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(server): remove the unlocked log-capture pattern from the remaining cmd/server tests (#301 follow-up) #310
Follow-up to #301 / #307. #307 fixed the harness-only race in TestHashMigrate_LogsMaxWriteLockHold_215: an unlocked read of the log-capture bytes.Buffer while background goroutines were still logging. The same anti-pattern remains in other cmd/server tests. The review of #307 also left four nits.
Same unlocked-capture pattern in 7 test files
These test files read a plain bytes.Buffer while the standard logger still points at it:
cdn_detection_test.go (two sites, plus one writerFunc)
issue199_node_not_found_test.go (two sites)
memlimit_test.go
neighbor_graph_geo_test.go
nodes_pagination_postfilter_test.go
ping_score_history_production_test.go
schema_degradation_per_store_test.go
The hazard is not limited to the index builders. Several other goroutines can outlive a test and write into a later test's capture:
OpenDB starts go d.healSchemaFlags().
runDistanceIndexBuild logs every build.
(*DB).Close logs the WAL checkpoint.
Several recomputers log from their own goroutines.
Two fixes would close the class:
Restore the writer before reading the buffer.log.SetOutput and (*Logger).output share outMu, so restoring first orders every in-flight logger write before the read. This is the cheapest option.
hash_migrate_log_race_301_test.go:41. The fixed time.Sleep(200 * time.Millisecond) is what makes the test a reliable race detector. Consider polling on syncBuffer's written channel, or a read func() string handed to fn.
hash_migrate_log_race_301_test.go:28-31. If store.Load() fails, t.Fatal fires while the gate goroutine is still blocked on <-release. Add defer close(release) after installing the gate.
Acceptance
No test in cmd/server reads a log-capture buffer without one of the two fixes above.
go test -race -count=20 on the touched tests is green.
Activity
Merge pull request #311 from dborup/codex/issue-310-log-capture-race
dborup commentedon Oct 6, 2026
Fixed by #311 (merged as
629a254a3b75f89d3ccdfca3f80edbc7960d662f).