Repository navigation
test(scheduler): capture logs in a lock-guarded buffer (fixes the data race failing main) - #1443
Merged
Merged
Conversation
…eness test main's Integration Tests (migrations, rest) failed on 89e1140 with a data race in TestAWSRecommendationCompletenessPersistence/SP_empty. The test points the process-wide logger at a plain bytes.Buffer and reads it with String(). Since LeanerCloud#1400 puts every subtest's database on one shared Postgres server, a connection pool from an earlier subtest can still be creating idle connections in a background goroutine (pgxpool createIdleResources), and its "context canceled" connect error is logged into the current subtest's buffer while the test reads it. The race detector fails the run. It's timing-dependent: the previous main run passed. Wrap the buffer in a small mutex-guarded type. Assertions unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25. Or wait 53 minutes for your next included review. View limit details
Comment |
Collaborator
Author
|
Merged by IAmJSD's agent at IAmJSD's request (acting owner): a fix for red main, merged as soon as the required checks passed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
main's CI failed on
89e11403(run 40287762269): Integration Tests (migrations, rest) reportedWARNING: DATA RACEinTestAWSRecommendationCompletenessPersistence/SP_empty(internal/scheduler).The test points the process-wide logger at a plain
bytes.Buffer(logging.SetOutput(&diagnostics)) and later readsdiagnostics.String()(line 305). Since #1400, every subtest's database lives on one shared Postgres server, so a connection pool from an earlier subtest can still be creating idle connections in pgxpool's background goroutine (createIdleResources). Its "context canceled" connect error is logged into the current subtest's buffer while the test reads it. That's a real unsynchronized read/write on the buffer, so the race detector fails the run. It's timing-dependent: main's previous run (f3498548) passed.What changed
Test-only: a small mutex-guarded
lockedBuffer(Write and String) replaces thebytes.Buffer. The assertions are unchanged.Verification
Linux, Go 1.26.10, Docker Postgres:
go test -race -tags integration -count=1 ./internal/scheduler/: okgo test -race -tags integration -count=5 -run TestAWSRecommendationCompletenessPersistence ./internal/scheduler/: ok, with no DATA RACE reportsgo test -race -short ./internal/scheduler/: ok; golangci-lint (integration tags) 0 issues; git-secrets clean🤖 Generated with Claude Code