Skip to content

Commit 2773373

Browse files
committed
fix: make take snapshot unsafe
1 parent 570e674 commit 2773373

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

magicblock-accounts-db/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,15 @@ impl AccountsDb {
282282
///
283283
/// Returns the state checksum computed at snapshot time.
284284
/// The checksum can be used to verify state consistency across nodes.
285-
pub fn take_snapshot(&self, slot: u64) -> AccountsDbResult<u64> {
285+
///
286+
///
287+
/// # Safety
288+
/// the caller must ensure that no state transitions are taking
289+
/// place concurrently when this operation is in progress
290+
pub unsafe fn take_snapshot(&self, slot: u64) -> AccountsDbResult<u64> {
286291
// Create snapshot directory (potential deep copy)
287292
self.flush();
288-
// SAFETY:
289-
// we have acquired the write lock above
290-
let checksum = unsafe { self.checksum() };
293+
let checksum = self.checksum();
291294
let used_storage = self.storage.active_segment();
292295

293296
let manager = self.snapshot_manager.clone();

magicblock-accounts-db/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ impl TestEnv {
691691

692692
/// Takes a snapshot and waits for archiving to complete.
693693
fn take_snapshot_and_wait(&self, slot: u64) -> u64 {
694-
let checksum = self.adb.take_snapshot(slot);
694+
let checksum = unsafe { self.adb.take_snapshot(slot) };
695695
// Wait for background archiving to complete
696696
let mut retries = 0;
697697
while !self.adb.snapshot_exists(slot) && retries < 200 {

0 commit comments

Comments
 (0)