chainlink icon indicating copy to clipboard operation
chainlink copied to clipboard

fix: correct nurse memory profile rate assignment

Open leslieo2 opened this issue 3 months ago • 1 comments

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 -race finding: 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

leslieo2 avatar Sep 23 '25 10:09 leslieo2

@Atrax1 please help to review this pr, thanks.

leslieo2 avatar Oct 08 '25 05:10 leslieo2

unverified commits - closing. pls sign properly.

mchain0 avatar Nov 14 '25 09:11 mchain0