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

Release Notes:

- N/A

Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Antonio Scandurra 2025-06-09 21:37:48 +02:00 committed by GitHub
parent 0b7583bae5
commit c4fd9e1a6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -501,8 +501,10 @@ impl Database {
/// Returns all channels for the user with the given ID. /// Returns all channels for the user with the given ID.
pub async fn get_channels_for_user(&self, user_id: UserId) -> Result<ChannelsForUser> { pub async fn get_channels_for_user(&self, user_id: UserId) -> Result<ChannelsForUser> {
self.transaction(|tx| async move { self.get_user_channels(user_id, None, true, &tx).await }) self.weak_transaction(
.await |tx| async move { self.get_user_channels(user_id, None, true, &tx).await },
)
.await
} }
/// Returns all channels for the user with the given ID that are descendants /// Returns all channels for the user with the given ID that are descendants

View file

@ -15,7 +15,7 @@ impl Database {
user_b_busy: bool, user_b_busy: bool,
} }
self.transaction(|tx| async move { self.weak_transaction(|tx| async move {
let user_a_participant = Alias::new("user_a_participant"); let user_a_participant = Alias::new("user_a_participant");
let user_b_participant = Alias::new("user_b_participant"); let user_b_participant = Alias::new("user_b_participant");
let mut db_contacts = contact::Entity::find() let mut db_contacts = contact::Entity::find()
@ -91,7 +91,7 @@ impl Database {
/// Returns whether the given user is a busy (on a call). /// Returns whether the given user is a busy (on a call).
pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool> { pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool> {
self.transaction(|tx| async move { self.weak_transaction(|tx| async move {
let participant = room_participant::Entity::find() let participant = room_participant::Entity::find()
.filter(room_participant::Column::UserId.eq(user_id)) .filter(room_participant::Column::UserId.eq(user_id))
.one(&*tx) .one(&*tx)

View file

@ -80,7 +80,7 @@ impl Database {
&self, &self,
user_id: UserId, user_id: UserId,
) -> Result<Option<proto::IncomingCall>> { ) -> Result<Option<proto::IncomingCall>> {
self.transaction(|tx| async move { self.weak_transaction(|tx| async move {
let pending_participant = room_participant::Entity::find() let pending_participant = room_participant::Entity::find()
.filter( .filter(
room_participant::Column::UserId room_participant::Column::UserId