fix(sync/v3): Stop ignoring leave cache deserialization failures

This commit is contained in:
Ginger 2025-11-06 10:02:02 -05:00
parent c2449bde74
commit d2cc2fb19b
2 changed files with 5 additions and 17 deletions

View file

@ -177,7 +177,7 @@ pub async fn leave_room(
.rooms .rooms
.state_cache .state_cache
.left_state(user_id, room_id) .left_state(user_id, room_id)
.await .await?
}, },
} }
}; };

View file

@ -430,16 +430,9 @@ pub async fn knock_state(
#[implement(Service)] #[implement(Service)]
#[tracing::instrument(skip(self), level = "trace")] #[tracing::instrument(skip(self), level = "trace")]
pub async fn left_state(&self, user_id: &UserId, room_id: &RoomId) -> Option<Pdu> { pub async fn left_state(&self, user_id: &UserId, room_id: &RoomId) -> Result<Option<Pdu>> {
let key = (user_id, room_id); let key = (user_id, room_id);
self.db self.db.userroomid_leftstate.qry(&key).await.deserialized()
.userroomid_leftstate
.qry(&key)
.await
.deserialized()
// old databases may have garbage data as values in the `userroomid_leftstate` table from before
// the leave event was stored there. they still need to be included, so we return Ok(None) for deserialization failures.
.unwrap_or(None)
} }
/// Returns an iterator over all rooms a user left. /// Returns an iterator over all rooms a user left.
@ -458,13 +451,8 @@ pub fn rooms_left<'a>(
.stream_prefix(&prefix) .stream_prefix(&prefix)
.ignore_err() .ignore_err()
.map(|((_, room_id), state): KeyVal<'_>| (room_id.to_owned(), state)) .map(|((_, room_id), state): KeyVal<'_>| (room_id.to_owned(), state))
.ready_filter_map(|(room_id, state)| { .map(|(room_id, state)| Ok((room_id, state.deserialize()?)))
// deserialization errors need to be ignored. see comment in `left_state` .ignore_err()
match state.deserialize() {
| Ok(state) => Some((room_id, state)),
| Err(_) => Some((room_id, None)),
}
})
} }
#[implement(Service)] #[implement(Service)]