commit_graph: add a sleep in update-preloaded command to prevent exiting before writing to all inner blobstores

Summary: In the case of a multiplexed blobstore, the put operation can exit after it succeeds in one inner blobstore before finishing in all, and leave the rest running in the background. This sleep tries to prevent exiting early before they all finish.

Reviewed By: mitrandir77

Differential Revision: D46190037

fbshipit-source-id: ac2ae0d1453ebdc923170b9da7ca98df7519bf52
This commit is contained in:
Youssef Ibrahim 2023-05-25 11:00:34 -07:00 committed by Facebook GitHub Bot
parent e95b17e5a6
commit 84661b9dd0

View File

@ -53,6 +53,10 @@ pub struct UpdatePreloadedArgs {
/// Sleep time between fetching changeset edges in milliseconds.
#[clap(long)]
sleep_ms: u64,
/// Sleep time before exiting the program in seconds.
#[clap(long, default_value_t = 60)]
sleep_before_exit_secs: u64,
}
async fn try_fetch_chunk(
@ -185,6 +189,11 @@ pub(super) async fn update_preloaded(
.put(ctx, args.blobstore_key, BlobstoreBytes::from_bytes(bytes))
.await?;
// In the case of a multiplexed blobstore, the put operation can exit after it succeeds
// in one inner blobstore before finishing in all, and leave the rest running in the
// background. This sleep tries to prevent exiting early before they all finish.
tokio::time::sleep(Duration::from_secs(args.sleep_before_exit_secs)).await;
println!("Uploaded updated preloaded edges to blobstore");
Ok(())