From f4ec303d1b5043ee2dfa1b760d87f80d706f651b Mon Sep 17 00:00:00 2001 From: Vimal Kumar Date: Wed, 28 Sep 2016 10:35:19 +0530 Subject: [PATCH] wal/wal.go: modified WAL.SaveSnapshot to do the Marshal before aquiring the mutex --- wal/wal.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wal/wal.go b/wal/wal.go index 0bd85c166..2b155acde 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -567,10 +567,11 @@ func (w *WAL) Save(st raftpb.HardState, ents []raftpb.Entry) error { } func (w *WAL) SaveSnapshot(e walpb.Snapshot) error { + b := pbutil.MustMarshal(&e) + w.mu.Lock() defer w.mu.Unlock() - b := pbutil.MustMarshal(&e) rec := &walpb.Record{Type: snapshotType, Data: b} if err := w.encoder.encode(rec); err != nil { return err