Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap PP from a SnapshotRepository snapshot #2288

Draft
wants to merge 2 commits into
base: feat/snapshot-upload
Choose a base branch
from

Conversation

pcholakov
Copy link
Contributor

No description provided.

@pcholakov pcholakov changed the title Feat/snapshot bootstrap Bootstrap PP from a SnapshotRepository snapshot Nov 13, 2024
Comment on lines +213 to +223
task_center()
.spawn_blocking_fn_unmanaged("unpack-snapshot", Some(partition_id), move || {
let mut tarball = tar::Archive::new(snapshot_reader);
for file in tarball.entries()? {
let mut file = file?;
trace!("Unpacking snapshot file: {:?}", file.header().path()?);
file.unpack_in(&snapshot_dir)?;
}
Ok::<(), anyhow::Error>(())
})
.await??;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially tried to use spawn_blocking_unmanaged here but got the following error:

"Cannot start a runtime from within a runtime. This happens because a function (like block_on) attempted to block the current thread while the thread is being used to drive asynchronous tasks."

This is not a problem in the earlier use in this file - on line 136, we spawn a future which also uses the tar crate to bundle up a local directory on the upload path, and that works just fine. The only difference here appears to be the use of SyncIoBridge to make the AsyncRead byte stream of the download into a Read for tar's Archive to consume.

I was also able to get this to work using plain vanilla tokio::task::spawn_blocking. It seems like the TaskCenter implementation using block_on is part of this but I'm not entirely sure what's going on.

self.inner
.default_runtime_handle
.block_on(self.run_in_scope(name, partition_id, future))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant