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
Conversation
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Summary
There were some db transactions that were not waiting for permits or running on threads so I fixed that.
TODO: