Fix concurrent snapshot read/write

This commit is contained in:
alesapin 2021-05-12 23:28:01 +03:00
parent 833f48751a
commit f2a8b5b2c6
2 changed files with 6 additions and 3 deletions

2
contrib/NuRaft vendored

@ -1 +1 @@
Subproject commit 377f8e77491d9f66ce8e32e88aae19dffe8dc4d7 Subproject commit 95d6bbba579b3a4e4c2dede954f541ff6f3dba51

View File

@ -267,12 +267,15 @@ int KeeperStateMachine::read_logical_snp_obj(
{ {
std::lock_guard lock(snapshots_lock); std::lock_guard lock(snapshots_lock);
if (s.get_last_log_idx() != latest_snapshot_meta->get_last_log_idx()) if (s.get_last_log_idx() != latest_snapshot_meta->get_last_log_idx())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Required to apply snapshot with last log index {}, but our last log index is {}", {
LOG_WARNING(log, "Required to apply snapshot with last log index {}, but our last log index is {}. Will ignore this one and retry",
s.get_last_log_idx(), latest_snapshot_meta->get_last_log_idx()); s.get_last_log_idx(), latest_snapshot_meta->get_last_log_idx());
return -1;
}
data_out = nuraft::buffer::clone(*latest_snapshot_buf); data_out = nuraft::buffer::clone(*latest_snapshot_buf);
is_last_obj = true; is_last_obj = true;
} }
return 0; return 1;
} }
void KeeperStateMachine::processReadRequest(const KeeperStorage::RequestForSession & request_for_session) void KeeperStateMachine::processReadRequest(const KeeperStorage::RequestForSession & request_for_session)