-
Notifications
You must be signed in to change notification settings - Fork 4.1k
server: Refactor node ID initialization #16363
Description
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.