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

Make all db transactions async #1145

Merged
merged 8 commits into from Dec 6, 2021
Merged

Make all db transactions async #1145

merged 8 commits into from Dec 6, 2021

Conversation

freesig
Copy link
Contributor

@freesig freesig commented Nov 30, 2021

Summary

There were some db transactions that were not waiting for permits or running on threads so I fixed that.

TODO:

  • CHANGELOG(s) updated with appropriate info
  • Just before pressing the merge button, ensure new entries to CHANGELOG(s) are still under the UNRELEASED heading

Comment on lines +638 to +643
let permit = env.conn_permit().await;
let res = tokio::task::spawn_blocking(move || {
let mut conn = env.from_permit(permit)?;
conn.p2p_gossip_query_agents(since_ms, until_ms, (*arc_set).clone())
})
.await;
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 not something that can be done inside p2p_gossip_query_agents so we don't forget to do it in other places?

Copy link
Member

Choose a reason for hiding this comment

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

maybe different types for a conn that waits for a permit vs one that doesn't? and then only define p2p_gossip_query_agents on the one that does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what is happening. It's only implemented for the PConnGuard

Copy link
Contributor

@neonphog neonphog left a comment

Choose a reason for hiding this comment

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

👍

@@ -54,7 +54,7 @@ pub trait AsP2pStateTxExt {
fn p2p_query_near_basis(&self, basis: u32, limit: u32) -> DatabaseResult<Vec<AgentInfoSigned>>;
}

impl AsP2pAgentStoreConExt for crate::db::PConn {
impl AsP2pAgentStoreConExt for crate::db::PConnGuard {
Copy link
Member

Choose a reason for hiding this comment

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

In regards to my comment about different types...perhaps here is where you'd split these methods into different traits depending on what kind of connection you want to use with them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't this already force them to use the PConnGuard which can only be created via a permit?

@freesig freesig merged commit 3b5acf5 into develop Dec 6, 2021
@freesig freesig deleted the fix-async-db branch December 6, 2021 07:14
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.

None yet

3 participants