Skip to content

server: Refactor node ID initialization #16363

@bdarnell

Description

@bdarnell

In order for a node to learn its node ID, it must first initialize its stores. The node ID is stored in Node.Descriptor.NodeID by Node.initNodeID. However, the Node.Descriptor struct is shared between the store and the node by a pointer passed to NewStore. Both store and node access this struct without synchronization (which is fine for everything but the node ID, as the rest of the fields are read-only after construction).

The Store needs to access the NodeDescriptor with proper synchronization, and we may need to do an audit to ensure that all such accesses can handle the possibility of accessing the node descriptor before it is fully initialized.

The node ID is only set once at startup, and this race is not triggered by our current startup sequence. Changing store initialization as in #16354 exposed the race.

Metadata

Metadata

Assignees

Labels

C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions