Merge pull request #6453 from vimalk78/wal-optimize-marshal-outside-lock

wal/wal.go: optimized WAL.SaveSnapshot to do Marshal outside the mutex lock
This commit is contained in:
Anthony Romano 2016-10-03 11:50:11 -07:00 committed by GitHub
commit c26ebe3262

View File

@ -579,10 +579,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