Fix datarace

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-10-03 15:35:20 -07:00
parent 1ccc6dbf30
commit 2d21bc7008

View File

@@ -654,9 +654,9 @@ func (s *Server) transferRaftLeaders() bool {
// This should only be called on the leader.
func (n *raft) Propose(data []byte) error {
n.RLock()
if n.state != Leader {
if state := n.state; state != Leader {
n.RUnlock()
n.debug("Proposal ignored, not leader (state: %v)", n.state)
n.debug("Proposal ignored, not leader (state: %v)", state)
return errNotLeader
}
// Error if we had a previous write error.