From 68c910a08377516f148bcb2cbc3a2993fda0d3cd Mon Sep 17 00:00:00 2001 From: Matija Santl Date: Wed, 13 Feb 2019 13:30:41 +0100 Subject: [PATCH] Simplify log compaction Summary: Teon found this nit so we might fix it. Reviewers: ipaljak Reviewed By: ipaljak Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1860 --- src/raft/raft_server.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/raft/raft_server.cpp b/src/raft/raft_server.cpp index 6c98c3a34..e8eb95227 100644 --- a/src/raft/raft_server.cpp +++ b/src/raft/raft_server.cpp @@ -982,6 +982,10 @@ void RaftServer::SnapshotThread() { VLOG(40) << "[LogCompaction] Creating snapshot."; bool status = durability::MakeSnapshot(*db_, *dba, durability_dir_, snapshot_filename); + + // Raft lock must be released when destroying dba object. + dba = nullptr; + lock.lock(); if (status) { @@ -1004,11 +1008,7 @@ void RaftServer::SnapshotThread() { disk_storage_.Delete(LogEntryKey(i)); } } - - lock.unlock(); - // Raft lock must be released when destroying dba object. - dba = nullptr; - } + } } std::this_thread::sleep_for(kSnapshotPeriod);