Skip to content

Commit

Permalink
Hotfix v1.2.0 david (#6436)
Browse files Browse the repository at this point in the history
* [backup-cli] print name when deleting stale metadata cache file

* [backup-cli] replay-verify: resumable

* [backup-cli] replay-verify: fix off-by-1 issue with --txns-to-skip

---------

Co-authored-by: aldenhu <[email protected]>
  • Loading branch information
davidiw and msmouse authored Feb 1, 2023
1 parent e169630 commit 895ae28
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
4 changes: 2 additions & 2 deletions execution/executor/src/chunk_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl<V: VMExecutor> TransactionReplayer for ChunkExecutorInner<V> {

transactions = remaining;
transaction_infos = remaining_info;
offset = version;
offset = version + 1;
}
self.replay_impl(transactions, transaction_infos)
}
Expand Down Expand Up @@ -412,7 +412,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {

info!(
"Overiding the output of txn at version: {:?}",
latest_view.version().unwrap(),
latest_view.version().map_or(0, |v| v + 1),
);

let chunk_output = ChunkOutput::by_transaction_output(
Expand Down
1 change: 1 addition & 0 deletions storage/backup/backup-cli/src/bin/replay-verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async fn main_impl() -> Result<()> {
Logger::new().level(Level::Info).init();

let opt = Opt::from_args();

let restore_handler = Arc::new(AptosDB::open(
opt.db_dir,
false, /* read_only */
Expand Down
38 changes: 29 additions & 9 deletions storage/backup/backup-cli/src/coordinators/replay_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,46 @@ impl ReplayVerifyCoordinator {
"start_version should precede end_version."
);

let state_snapshot = if self.start_version == 0 {
None
let run_mode = Arc::new(RestoreRunMode::Restore {
restore_handler: self.restore_handler,
});
let next_txn_version = run_mode.get_next_expected_transaction_version()?;
let (state_snapshot, replay_transactions_from_version) = if next_txn_version != 0 {
// DB is already in workable state
info!(
next_txn_version = next_txn_version,
"DB already has non-empty State DB.",
);
(None, next_txn_version)
} else if let Some(version) = run_mode.get_in_progress_state_snapshot()? {
info!(
version = version,
"Found in progress state snapshot restore",
);
(Some(metadata_view.expect_state_snapshot(version)?), version)
} else if self.start_version == 0 {
(None, 0)
} else {
metadata_view.select_state_snapshot(self.start_version.wrapping_sub(1))?
let state_snapshot = metadata_view.select_state_snapshot(self.start_version - 1)?;
let replay_transactions_from_version =
state_snapshot.as_ref().map(|b| b.version + 1).unwrap_or(0);
(state_snapshot, replay_transactions_from_version)
};
let replay_transactions_from_version =
state_snapshot.as_ref().map(|b| b.version + 1).unwrap_or(0);
ensure!(
next_txn_version <= self.start_version,
"DB version is already beyond start_version requested.",
);

let transactions = metadata_view.select_transaction_backups(
// transaction info at the snapshot must be restored otherwise the db will be confused
// about the latest version after snapshot is restored.
replay_transactions_from_version.saturating_sub(1),
self.end_version,
)?;

let global_opt = GlobalRestoreOptions {
target_version: self.end_version,
trusted_waypoints: Arc::new(self.trusted_waypoints_opt.verify()?),
run_mode: Arc::new(RestoreRunMode::Restore {
restore_handler: self.restore_handler,
}),
run_mode,
concurrent_downloads: self.concurrent_downloads,
replay_concurrency_level: 0, // won't replay, doesn't matter
};
Expand Down
2 changes: 1 addition & 1 deletion storage/backup/backup-cli/src/metadata/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub async fn sync_and_load(
for h in stale_local_hashes {
let file = cache_dir.join(h);
remove_file(&file).await.err_notes(&file)?;
info!("Deleted stale metadata files in cache.");
info!(file_name = h, "Deleted stale metadata file in cache.");
}

let num_new_files = new_remote_hashes.len();
Expand Down

0 comments on commit 895ae28

Please sign in to comment.