From be21d90108a1ded3f20b158acec3ee89a65bead2 Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Wed, 27 Jan 2016 20:18:19 +1100 Subject: [PATCH] raft/doc: add notice about thread safety of messages Fixes #4285 --- raft/doc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raft/doc.go b/raft/doc.go index ba6dc058e..8b2401cf6 100644 --- a/raft/doc.go +++ b/raft/doc.go @@ -81,6 +81,10 @@ no messages be sent until after the latest HardState has been persisted to disk, and all Entries written by any previous Ready batch (Messages may be sent while entries from the same batch are being persisted). If any Message has type MsgSnap, call Node.ReportSnapshot() after it has been sent (these messages may be large). +Note: Marshalling messages is not thread-safe; it is important that you +make sure that no new entries are persisted while marshalling. +The easiest way to achieve this is to serialise the messages directly inside +your main raft loop. 3. Apply Snapshot (if any) and CommittedEntries to the state machine. If any committed Entry has Type EntryConfChange, call Node.ApplyConfChange()