Constrain memory ordering on AccountsDb::write_version (#21312)

This commit is contained in:
Brooks Prumo
2021-11-17 07:11:16 -06:00
committed by GitHub
parent 6546c3cbae
commit c3e5927d16
3 changed files with 5 additions and 5 deletions

View File

@ -4391,7 +4391,7 @@ impl AccountsDb {
fn bulk_assign_write_version(&self, count: usize) -> StoredMetaWriteVersion { fn bulk_assign_write_version(&self, count: usize) -> StoredMetaWriteVersion {
self.write_version self.write_version
.fetch_add(count as StoredMetaWriteVersion, Ordering::Relaxed) .fetch_add(count as StoredMetaWriteVersion, Ordering::AcqRel)
} }
fn write_accounts_to_storage<F: FnMut(Slot, usize) -> Arc<AccountStorageEntry>>( fn write_accounts_to_storage<F: FnMut(Slot, usize) -> Arc<AccountStorageEntry>>(
@ -9193,8 +9193,8 @@ pub mod tests {
let daccounts = reconstruct_accounts_db_via_serialization(&accounts, latest_slot); let daccounts = reconstruct_accounts_db_via_serialization(&accounts, latest_slot);
assert_eq!( assert_eq!(
daccounts.write_version.load(Ordering::Relaxed), daccounts.write_version.load(Ordering::Acquire),
accounts.write_version.load(Ordering::Relaxed) accounts.write_version.load(Ordering::Acquire)
); );
// Get the hash for the latest slot, which should be the only hash in the // Get the hash for the latest slot, which should be the only hash in the

View File

@ -536,7 +536,7 @@ where
.store(next_append_vec_id, Ordering::Relaxed); .store(next_append_vec_id, Ordering::Relaxed);
accounts_db accounts_db
.write_version .write_version
.fetch_add(snapshot_version, Ordering::Relaxed); .fetch_add(snapshot_version, Ordering::Release);
let mut measure_notify = Measure::start("accounts_notify"); let mut measure_notify = Measure::start("accounts_notify");

View File

@ -242,7 +242,7 @@ impl<'a> TypeContext<'a> for Context {
let version = serializable_db let version = serializable_db
.accounts_db .accounts_db
.write_version .write_version
.load(Ordering::Relaxed); .load(Ordering::Acquire);
// (1st of 3 elements) write the list of account storage entry lists out as a map // (1st of 3 elements) write the list of account storage entry lists out as a map
let entry_count = RefCell::<usize>::new(0); let entry_count = RefCell::<usize>::new(0);