chainlink
chainlink copied to clipboard
fix: correct nurse memory profile rate assignment
External contribution; no internal ticket.
Requires
None.
Supports
None.
Summary
- set runtime.MemProfileRate from the configured mem profile rate instead of the block profile rate
- update the nurse mock config to use distinct profiling rates so the test can catch regressions
- assert that Nurse startup applies the configured memory profile rate
Background
- commit 7efb04d41b3c (BCF-2099) addressed a
go test -racefinding: the Nurse test started the service (which writes runtime.MemProfileRate) while other goroutines were also touching that runtime global, triggering “data race on runtime.MemProfileRate” - to reduce writes to the runtime variable they wrapped the assignment in a guard, but accidentally copied AutoPprofBlockProfileRate instead of AutoPprofMemProfileRate, leaving the mem profile rate stuck to the block profile value
- later refactors (e.g. 69f7bd68199) kept the same line, so the regression persisted until now
Rationale
- restoring the mem profile rate ensures heap profiling obeys configuration while keeping the conditional guard that prevents the original race
- the updated test resets runtime.MemProfileRate before startup, asserts the new value, and cleans up, so it exercises the fix without reintroducing the prior race condition
Testing
- GOTOOLCHAIN=go1.24.7 GOCACHE=$(pwd)/.gocache go test ./core/services -run TestNurse -count=1
@Atrax1 please help to review this pr, thanks.
unverified commits - closing. pls sign properly.