Skip to content

Commit

Permalink
tests(resolver): fix data race introduced by querylog ignore
Browse files Browse the repository at this point in the history
Race only happens in tests: the write removed here can happen at the
same time as `writeLog` is reading the struct field since cancelling
the context doesn't guarantee immediate shutdown.
We can just use the existing channel so the field becomes read-only,
avoiding the race.

Example CI failure:
https://github.com/0xERR0R/blocky/actions/runs/8632315589/job/23662702020

For local repro, adding a 2ms sleep to `writeLog`'s startup was enough
for me.
  • Loading branch information
ThinkChaos committed Apr 11, 2024
1 parent ef8c008 commit dbd1390
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions resolver/query_logging_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ var _ = Describe("QueryLoggingResolver", func() {
ctx, cancelFn = context.WithCancel(context.Background())
DeferCleanup(cancelFn)

// Capture written logs
sut.logChan = make(chan *querylog.LogEntry, 16)

// Capture ignored logs
{
var logger *logrus.Entry
Expand Down

0 comments on commit dbd1390

Please sign in to comment.