History

Switch to using weak transactions for queries happening on connection (#32411)

Release Notes: - N/A

Antonio Scandurra committed 1 year ago

Commit c4fd9e11 parent 0b7583b3 files · +7 −5Browse files

Unified · Split

3 files
  1. crates/collab/src/db/queries/channels.rs +4 −2
  2. crates/collab/src/db/queries/contacts.rs +2 −2
  3. crates/collab/src/db/queries/rooms.rs +1 −1
crates/collab/src/db/queries/channels.rs+4−2
@@ -501,8 +501,10 @@ impl Database { · 500 unmodified lines
501 501
502 /// Returns all channels for the user with the given ID.502 /// Returns all channels for the user with the given ID.
503 pub async fn get_channels_for_user(&self, user_id: UserId) -> Result<ChannelsForUser> {503 pub async fn get_channels_for_user(&self, user_id: UserId) -> Result<ChannelsForUser> {
504 self.transaction(|tx| async move { self.get_user_channels(user_id, None, true, &tx).await })504 self.weak_transaction(
505 .await505 |tx| async move { self.get_user_channels(user_id, None, true, &tx).await },
506 )
507 .await
506 }508 }
507 509
508 /// Returns all channels for the user with the given ID that are descendants510 /// Returns all channels for the user with the given ID that are descendants
crates/collab/src/db/queries/contacts.rs+2−2
@@ -15,7 +15,7 @@ impl Database { · 14 unmodified lines
15 user_b_busy: bool,15 user_b_busy: bool,
16 }16 }
17 17
18 self.transaction(|tx| async move {18 self.weak_transaction(|tx| async move {
19 let user_a_participant = Alias::new("user_a_participant");19 let user_a_participant = Alias::new("user_a_participant");
20 let user_b_participant = Alias::new("user_b_participant");20 let user_b_participant = Alias::new("user_b_participant");
21 let mut db_contacts = contact::Entity::find()21 let mut db_contacts = contact::Entity::find()
@@ -91,7 +91,7 @@ impl Database { · 69 unmodified lines
91 91
92 /// Returns whether the given user is a busy (on a call).92 /// Returns whether the given user is a busy (on a call).
93 pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool> {93 pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool> {
94 self.transaction(|tx| async move {94 self.weak_transaction(|tx| async move {
95 let participant = room_participant::Entity::find()95 let participant = room_participant::Entity::find()
96 .filter(room_participant::Column::UserId.eq(user_id))96 .filter(room_participant::Column::UserId.eq(user_id))
97 .one(&*tx)97 .one(&*tx)
crates/collab/src/db/queries/rooms.rs+1−1
@@ -80,7 +80,7 @@ impl Database { · 79 unmodified lines
80 &self,80 &self,
81 user_id: UserId,81 user_id: UserId,
82 ) -> Result<Option<proto::IncomingCall>> {82 ) -> Result<Option<proto::IncomingCall>> {
83 self.transaction(|tx| async move {83 self.weak_transaction(|tx| async move {
84 let pending_participant = room_participant::Entity::find()84 let pending_participant = room_participant::Entity::find()
85 .filter(85 .filter(
86 room_participant::Column::UserId86 room_participant::Column::UserId