fix(services): HealthChecker.Register immediately populates cache when already running#1976
Open
fix(services): HealthChecker.Register immediately populates cache when already running#1976
Conversation
|
Fletch153
added a commit
to smartcontractkit/chainlink
that referenced
this pull request
Apr 10, 2026
HealthChecker.Register() now signals the polling goroutine to run update() immediately when the checker is already running, eliminating the up-to-15-second window where a dynamically registered service (e.g. a spawned job) was absent from IsHealthy() / IsReady() even though Ready() already returned nil. Fixes CORE-2386. Companion chainlink-common PR: smartcontractkit/chainlink-common#1976
f6b9ba9 to
e76df7d
Compare
Fletch153
added a commit
to smartcontractkit/chainlink
that referenced
this pull request
Apr 10, 2026
HealthChecker.Register() now signals the polling goroutine to run update() immediately when the checker is already running, eliminating the up-to-15-second window where a dynamically registered service (e.g. a spawned job) was absent from IsHealthy() / IsReady() even though Ready() already returned nil. Fixes CORE-2386. Companion chainlink-common PR: smartcontractkit/chainlink-common#1976
e76df7d to
d2ac04e
Compare
Fletch153
added a commit
to smartcontractkit/chainlink
that referenced
this pull request
Apr 10, 2026
HealthChecker.Register() now signals the polling goroutine to run update() immediately when the checker is already running, eliminating the up-to-15-second window where a dynamically registered service (e.g. a spawned job) was absent from IsHealthy() / IsReady() even though Ready() already returned nil. Fixes CORE-2386. Companion chainlink-common PR: smartcontractkit/chainlink-common#1976
d2ac04e to
07a72b4
Compare
Fletch153
added a commit
to smartcontractkit/chainlink
that referenced
this pull request
Apr 10, 2026
HealthChecker.Register() now signals the polling goroutine to run update() immediately when the checker is already running, eliminating the up-to-15-second window where a dynamically registered service (e.g. a spawned job) was absent from IsHealthy() / IsReady() even though Ready() already returned nil. Fixes CORE-2386. Companion chainlink-common PR: smartcontractkit/chainlink-common#1976
mchain0
previously approved these changes
Apr 13, 2026
jmank88
requested changes
Apr 13, 2026
jmank88
reviewed
Apr 13, 2026
jmank88
previously approved these changes
Apr 13, 2026
cbc6906 to
1fdf090
Compare
1fdf090 to
111cd0b
Compare
Replace the chRefresh channel mechanism with direct map population in Register(). Instead of signaling the run() goroutine to call update() (which re-checks ALL services), Register() now directly populates c.ready and c.healthy for just the newly registered service. This is simpler and avoids unnecessary re-polling of all services.
111cd0b to
575541a
Compare
Fix missing servicesMu.Unlock() in Unregister that would cause a deadlock on every call. Revert unrelated whitespace alignment changes to struct definition and New() constructor.
mchain0
approved these changes
Apr 13, 2026
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.
Summary
Register()is called on an already-startedHealthChecker(e.g. by the job spawner after starting a new job service), the new service's health state is absent fromIsHealthy()/IsReady()for up to 15 seconds — the full polling interval — even thoughReady()already returns nil.Register()now callsIfStartedafter adding the service, immediately populatingc.readyandc.healthyfor that service.servicesMuwrite lock is scoped to an inner closure and released before callingIfStartedto avoid a deadlock withStart(), which holds theStateMachinelock while callingupdate()(which acquiresservicesMu.RLock).Changes
pkg/services/health.go—Register()triggers an immediate single-service health check when the checker is already runningpkg/services/health_test.go— two new tests covering healthy and unhealthy services registered on a running checkerTest plan
go test ./pkg/services/... -run TestHealthChecker_Register— both new tests passgo test ./pkg/services/...— no regressions🤖 Generated with Claude Code