Skip to content

Commit

Permalink
Merge branch 'main' into rpc_sessions_locks
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Nov 11, 2024
2 parents 22ce4d4 + d8020c0 commit e664aac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/node/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ namespace ccf
bool init_from_snapshot(
const std::vector<uint8_t>& hash_at_snapshot) override
{
std::lock_guard<ccf::pal::Mutex> guard(state_lock);
// The history can be initialised after a snapshot has been applied by
// deserialising the tree in the signatures table and then applying the
// hash of the transaction at which the snapshot was taken
Expand All @@ -688,6 +687,10 @@ namespace ccf
return false;
}

// Delay taking this lock until _after_ the read above, to avoid lock
// inversions
std::lock_guard<ccf::pal::Mutex> guard(state_lock);

CCF_ASSERT_FMT(
!replicated_state_tree.in_range(1),
"Tree is not empty before initialising from snapshot");
Expand Down

0 comments on commit e664aac

Please sign in to comment.