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

Let ProgramStorage::external be async #1291

Merged
merged 5 commits into from
May 24, 2024
Merged

Conversation

coolreader18
Copy link
Collaborator

@coolreader18 coolreader18 commented May 23, 2024

Description of Changes

Also: remove sled object_db. Merging that in from #1245.

Expected complexity level and risk

1

@coolreader18 coolreader18 requested a review from kim May 23, 2024 20:42
@coolreader18 coolreader18 force-pushed the noa/async-program-storage branch 5 times, most recently from 1ee3fbf to e307d29 Compare May 23, 2024 22:11
@coolreader18 coolreader18 force-pushed the noa/async-program-storage branch from e307d29 to 6f6c1f4 Compare May 24, 2024 05:43

fs::rename(tmp, path).await?;
}
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this even possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it was causing errors in CI - all the tests upload the same module simultaneously, I think.

@@ -46,37 +48,57 @@ type HostCell = Arc<AsyncRwLock<Option<Host>>>;
/// The registry of all running hosts.
type Hosts = Arc<Mutex<IntMap<u64, HostCell>>>;

type ExternalStorage = dyn Fn(&Hash) -> anyhow::Result<Option<AnyBytes>> + Send + Sync + 'static;
type SameDbStorage = dyn Fn(&RelationalDB, &Hash) -> anyhow::Result<Option<AnyBytes>> + Send + Sync + 'static;
#[async_trait]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need async_trait still?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes - it lets the future borrow from the ExternalStorage, rather than having to be 'static

debug!("lookup program {}", program_hash);
match self {
ProgramStorage::External(external) => external.lookup(program_hash).await,
ProgramStorage::SameDb(f) => f(db, program_hash),
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if this should be spawn blocking, just in case the same thread has a tx open…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, probably - but we can cross that when we get to actually using it.

@@ -89,7 +111,7 @@ pub struct HostController {
/// The directory to create database instances in.
///
/// For example:
///
///>
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, nothing

@@ -1,34 +0,0 @@
use crate::{
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

@coolreader18 coolreader18 enabled auto-merge May 24, 2024 16:43
@coolreader18 coolreader18 added this pull request to the merge queue May 24, 2024
Merged via the queue into master with commit 55b7cbe May 24, 2024
6 checks passed
@coolreader18 coolreader18 deleted the noa/async-program-storage branch May 24, 2024 21:45
@coolreader18 coolreader18 restored the noa/async-program-storage branch May 25, 2024 01:07
@coolreader18 coolreader18 deleted the noa/async-program-storage branch May 25, 2024 01:08
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.

2 participants