fix: stuck messages
Conduit did not send the event in /sync because of a race condition. There is a brief moment in time where Conduit accepted the event, but did not store it yet. So when the client /syncs it updates the since token without sending the event. I hope I fixed it by significantly shortening the race-condition period.
This commit is contained in:
parent
8c44312485
commit
1c25492a7e
4 changed files with 19 additions and 25 deletions
|
@ -1579,21 +1579,14 @@ pub(crate) fn append_incoming_pdu(
|
|||
new_room_leaves: HashSet<EventId>,
|
||||
state: &StateMap<Arc<PduEvent>>,
|
||||
) -> Result<Vec<u8>> {
|
||||
let count = db.globals.next_count()?;
|
||||
let mut pdu_id = pdu.room_id.as_bytes().to_vec();
|
||||
pdu_id.push(0xff);
|
||||
pdu_id.extend_from_slice(&count.to_be_bytes());
|
||||
|
||||
// We append to state before appending the pdu, so we don't have a moment in time with the
|
||||
// pdu without it's state. This is okay because append_pdu can't fail.
|
||||
db.rooms
|
||||
.set_event_state(&pdu.event_id, state, &db.globals)?;
|
||||
|
||||
db.rooms.append_pdu(
|
||||
let pdu_id = db.rooms.append_pdu(
|
||||
pdu,
|
||||
pdu_json,
|
||||
count,
|
||||
&pdu_id,
|
||||
&new_room_leaves.into_iter().collect::<Vec<_>>(),
|
||||
&db,
|
||||
)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue