You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change checks for no-ops just before committing, and avoids writing
them to the database.
Motivation
----------
Sometimes we have situations where multiple clients try to make an
identical change to the same document at the same time (if multiple
clients are trying to keep two documents in sync, for example).
When this happens, this can result in a `O(n^2)` retry cascade, since
the requests will all keep retrying, with only a single request
succeeding at a time, even if those ops are all no-ops.
Solution
--------
This change adds a new special `ERR_NO_OP` error code. If the server
detects a no-op, it will skip committing, and early-return this error
code, which takes the request out of the retry queue.
The client then has some special handling for this case, where it will:
1. Fetch from remote to get up-to-date with any potential conflicting
ops
2. Then acknowledge the in-flight op, **without** bumping the version
(since the op wasn't committed)
Note that if `$fixup()` has been used, we **do not** early-return a
no-op error, even if the fixup results in a no-op, since the client
would be left in an inconsistent state without the fixup ops being
returned and applied.
Copy file name to clipboardexpand all lines: docs/api/sharedb-error.md
+6
Original file line number
Diff line number
Diff line change
@@ -100,3 +100,9 @@ Representation of an error, with a machine-parsable [code](#error-codes).
100
100
### `ERR_TYPE_CANNOT_BE_PROJECTED`
101
101
102
102
> The document's type cannot be projected. [`json0`]({{ site.baseurl }}{% link types/json0.md %}) is currently the only type that supports projections.
103
+
104
+
### `ERR_NO_OP`
105
+
106
+
> The submitted op resulted in a no-op, possibly after transformation by a remote op.
107
+
108
+
> This is normal behavior and the client should swallow this error without bumping doc version.
0 commit comments