Fix slow commit bug
This commit is contained in:
parent
eb23f445d0
commit
0329fc29f2
1 changed files with 88 additions and 40 deletions
|
|
@ -793,23 +793,18 @@ impl Database {
|
|||
.await
|
||||
.context("Failed to commit transaction")?;
|
||||
|
||||
// For non-delete writes the originating device already has
|
||||
// authoritative state from its HTTP response, so we tag the
|
||||
// broadcast with `origin_device_id` and the send task in
|
||||
// `websocket.rs` filters it out for that device. Deletes are
|
||||
// delivered to *every* connected client including the author —
|
||||
// the originator only removes the document from its sync queue
|
||||
// once it receives this receipt.
|
||||
// Broadcast every commit to every connected client, including
|
||||
// the originator. The HTTP response is the originator's normal
|
||||
// path to learn its own update, but if the response is lost
|
||||
// (sync reset, dropped TCP) the broadcast is the only remaining
|
||||
// delivery channel — and the client-side `parentVersionId`
|
||||
// dedup absorbs the redundant message when the response made it
|
||||
// through.
|
||||
let envelope = WebSocketServerMessage::VaultUpdate(WebSocketVaultUpdate {
|
||||
document: version.clone().into(),
|
||||
});
|
||||
let with_origin = if version.is_deleted {
|
||||
WebSocketServerMessageWithOrigin::new(envelope)
|
||||
} else {
|
||||
WebSocketServerMessageWithOrigin::with_origin(version.device_id.clone(), envelope)
|
||||
};
|
||||
self.broadcasts
|
||||
.send_document_update(vault_id, with_origin)?;
|
||||
.send_document_update(vault_id, WebSocketServerMessageWithOrigin::new(envelope))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue