ci: run the race detector for the modules that are already race-clean - #1461
ci: run the race detector for the modules that are already race-clean#1461dwin-gharibi wants to merge 1 commit into
Conversation
Signed-off-by: Dwin Gharibi <dwin.gharibi@email.kntu.ac.ir>
| .PHONY: cubedb-test | ||
| cubedb-test: | ||
| cd CubeDB && go mod download && go test ./... | ||
| cd CubeDB && go mod download && go test -race ./... |
There was a problem hiding this comment.
Low — -race adds a C-toolchain requirement at test time, even though CubeDB is pure Go.
The race detector needs cgo enabled plus a working C compiler (gcc/clang) when the test binary links — being "pure Go with no CGO" (the Makefile comment at lines 400-402) doesn't help here. On any host where CGO_ENABLED=0 is exported — a pattern this repo itself uses for its production builds (Makefile:313, Makefile:330, Makefile:374, CubeDB/…-adjacent Dockerfiles) — this target will now hard-fail with go: -race requires cgo; enable cgo during builds.
CI is fine: unit-test-check.yml runs this on GitHub-hosted runners that ship gcc, and cube-lifecycle-manager-test runs inside the builder image which installs build-essential/clang (docker/Dockerfile.builder:81-137). But local developers following the repo's CGO_ENABLED=0 convention will break. Consider documenting the new requirement, or failing with a clearer message when go env CGO_ENABLED is 0.
AI-generated review summaryReviewed PR #1461 ( Verdict: no blocking issues. The change is consistent, well-scoped, and the deliberate staging of the currently-red targets ( What the change does (verified against base tree)
Findings
ConclusionApprove. This is a clean, well-motivated CI change that establishes a race-detector gate for four modules immediately without blocking on the red ones. No correctness issues in the diff itself; the only actionable item is documenting the new cgo requirement for local/ |
Closes #1460.
Motivation
Nothing in the repo passes
-racetogo test, so concurrency bugs ship undetected. Enabling it surfaces12 races and 12 failing tests today — five of the races in production code, including a torn
interface{}read in
CubeMaster/pkg/base/localcache.What this changes
Adds
-raceto the four modules that are already clean, so this can land immediately without waiting onany fix:
cubelog-testMakefile:356cubedb-testMakefile:360cube-lifecycle-manager-testMakefile:364tests/unittest/run_sdk_test.sh:72Nothing else changes — same packages, same flags otherwise.
Deliberately staged
cubeops-test,cubemaster-testandcubelet-pkg-testare not switched on here, because they are redtoday and this PR would fail CI on arrival. They should be enabled as a follow-up once the corresponding
fixes land:
cubeops-testcachingFakeFetchOnlymap-read race ininternal/handler/store_test.gocubemaster-testlocalcacheproduction races, plus thequeueworker/recov/bufferqueuetest racescubelet-pkg-testqueueworker/recovtest racesEach of those has its own branch. Landing this PR first means the gate exists and every new module or
package added to these four targets is race-checked from day one.
Testing
All four gated modules verified clean under the detector:
(
go test -race -count=1 ./...per module, countingWARNING: DATA RACEandFAILlines.)Cost
-racetypically costs 2-5x runtime and ~5-10x memory. These four are the small, fast modules — the oneswhose runtime is dominated by process startup rather than the tests themselves — so the CI impact is
minimal. The expensive modules (CubeMaster, Cubelet) are the ones deliberately left for the follow-up, which
is a good moment to measure the real cost before committing to it.
cubelog-testkeeps-short, so the long-running cases stay skipped.