security: `security_certificate_expiration_node_client` metric not updated after SIGHUP cert reload
Summary
The security_certificate_expiration_node_client Prometheus metric does not reflect the updated expiry value after a certificate reload via SIGHUP. The metric only updates after a full node restart. This affects both 24.3.11 and 25.2.4/25.2.6.
This is a distinct issue from the security_certificate_expiration_client cache bug (GH #142681 / #151040), which is about the per-SQL-user cache. This metric (node_client) is backed by a FunctionalGauge with a direct closure — no cert cache is involved.
Steps to Reproduce
- Create a cluster with a node client certificate (
client.node.crt). - Replace the certificate using
--overwriteand a new--lifetimeflag (same filename, same directory). - Send
SIGHUPto the CockroachDB process:kill -HUP <cockroach_pid> - Verify the reload succeeded — logs should show
certs_reload: Success: true. - Confirm new expiry is on disk:
cockroach cert list - Scrape the metric:
curl -sk https://localhost:8080/_status/vars | grep 'security_certificate_expiration_node_client'
Expected Behavior
The metric reflects the new certificate's expiry timestamp after the SIGHUP reload.
Actual Behavior
The metric remains stuck on the old expiry value. Bouncing the node (full restart) causes the metric to update correctly.
Root Cause Analysis
Traced through release-25.2:
SIGHUP→cm.LoadCertificates()→ creates a newCertificateLoader, reads cert files from disk, parses them, and undercm.mu.Lock()swapscm.nodeClientCertwith the newCertInfo. This path appears correct and the success log confirms the new cert is parsed.NodeClientExpirationis a*metric.Gaugecreated viaNewFunctionalGauge. On each Prometheus scrape:ToPrometheusMetric()→Value()→fn()→ readscm.nodeClientCert→ returnsci.ExpirationTime.Unix().
However, the closure in NodeClientExpiration reads cm.nodeClientCert without acquiring cm.mu.RLock(), unlike NodeExpiration which goes through cm.NodeCert() (a method that properly acquires the read lock). This is a data race that could cause the scrape to see a stale value of cm.nodeClientCert — potentially indefinitely depending on CPU/memory visibility.
The same race condition likely affects other metrics that read cert fields directly without the lock.
Additional Context
- Customer replaces
client.node.crtandclient.root.crtin-place (same filenames, same directory), sendsSIGHUPto the correct PID (verified viaps -fp), and seescerts_reload: Success: truein logs. cockroach cert listshows the correct new expiry on disk post-reload.- Prometheus metric remains stale until node restart.
Jira issue: CRDB-62054
Hi @aa-joshi, please add a branch-* label to identify the earliest affected branch for this C-bug
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
This issue has multiple T-eam labels. Please make sure it only has one, or else issue synchronization will not work correctly.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
This issue has multiple T-eam labels. Please make sure it only has one, or else issue synchronization will not work correctly.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
Hi @aa-joshi, please add a branch-* label to identify the earliest affected branch for this C-bug
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.