Skip to content

Fix node certificate synchronization - #8135

Merged
Amaury Chamayou (achamayou) merged 5 commits into
mainfrom
agents/ccf-8123-certificates
Aug 13, 2026
Merged

Fix node certificate synchronization#8135
Amaury Chamayou (achamayou) merged 5 commits into
mainfrom
agents/ccf-8123-certificates

Conversation

@achamayou

Copy link
Copy Markdown
Member

Summary

  • protect mutable node certificates with a dedicated mutex and use stable copies outside its lock scope
  • make NodeClient own immutable certificate snapshots instead of references into NodeState
  • update recovery-decision-protocol readers and add focused ownership coverage

Issue #8123 coverage

This PR resolves Still Applicable item 3, certificate state lock ordering and ownership:

  • certificate KV hooks no longer take the broad NodeState::lock
  • both mutable node certificate fields are protected by a dedicated mutex
  • certificate lock scopes cover only snapshot publication and never span TLS, history, node-to-node channel, frontend, or RPC work
  • asynchronous NodeClient users retain immutable certificate snapshots rather than references that can race renewal

This PR does not resolve items 4-6 or the remaining AFT startup question.

Testing

  • Clang 18 Debug builds: node_client_test, ccf, logging
  • build-local/tests.sh -R '^node_client_test$'
  • focused three-node certificate renewal rollback/re-election partition scenario
  • TSAN build and the same focused unit and partition scenario
  • rebased onto Fix RpcFrontend consensus and history publication #8127, then rebuilt node_client_test and ccf and reran the focused unit test
  • C++/CMake formatting, include, copyright, ASCII, and diff checks

Partially addresses #8123

Protect mutable node certificates with a dedicated mutex and use stable copies outside the lock. Make NodeClient own immutable certificate snapshots so retired-node cleanup cannot race certificate renewal.\n\nAddresses item 3 of #8123.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@achamayou
Amaury Chamayou (achamayou) requested a review from a team as a code owner August 10, 2026 14:08
Copilot AI lite review requested due to automatic review settings August 10, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves node certificate synchronization in NodeState by separating certificate mutation from the broad NodeState::lock, publishing stable certificate snapshots under a dedicated mutex, and ensuring asynchronous internal RPC users (NodeClient) retain immutable certificate copies to avoid races during renewal.

Changes:

  • Introduce a dedicated node_certificates_lock in NodeState and use it to protect reads/writes of mutable node certificate state.
  • Change NodeClient/HTTPNodeClient to store certificate snapshots by value (immutable) instead of references into NodeState.
  • Add a focused unit test (node_client_test) and update recovery-decision-protocol certificate readers to use stable snapshot access.

Custom instructions used:

  • .github/copilot-instructions.md
  • .github/instructions/reviewing.instructions.md

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/node/node_state.h Adds a dedicated certificate mutex, narrows certificate lock scopes, and passes stable certificate snapshots to TLS/session setup and internal clients.
src/node/node_client.h Switches certificate ownership from references to immutable by-value snapshots.
src/node/http_node_client.h Updates constructor/ownership to pass certificate snapshots into the base NodeClient.
src/node/recovery_decision_protocol.cpp Uses NodeState certificate snapshot accessor and avoids holding broad locks while preparing authenticated messages.
src/node/test/node_client.cpp Adds a unit test verifying NodeClient retains certificate snapshots after source mutation.
CMakeLists.txt Registers the new node_client_test unit test target.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comment thread src/node/node_state.h
Comment thread src/node/test/node_client.cpp
Comment thread src/node/node_state.h

@maxtropets Max (maxtropets) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd say Eddy should have a look, I'm not a lock-master

@maxtropets Max (maxtropets) added the run-long-test Run Long Test job label Aug 10, 2026
@achamayou

Copy link
Copy Markdown
Member Author

Eddy Ashton (@eddyashton) can you have a look please?

@eddyashton Eddy Ashton (eddyashton) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If LONG_TEST (TSAN) is happy, I'm happy.

@achamayou

Copy link
Copy Markdown
Member Author

If LONG_TEST (TSAN) is happy, I'm happy.

We won't quite have a full happy until the other nodestate lock re-reorderings are complete and we can remove the suppressions (#8144, #8139 and one more that does not exist yet for the frontends).

@achamayou
Amaury Chamayou (achamayou) merged commit 0c272f6 into main Aug 13, 2026
18 of 19 checks passed
@achamayou
Amaury Chamayou (achamayou) deleted the agents/ccf-8123-certificates branch August 13, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-long-test Run Long Test job

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants