Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Avoid committing no-ops to the database #682

Merged
merged 1 commit into from
Oct 15, 2024

Commits on Oct 15, 2024

  1. ⚡️ Avoid committing no-ops to the database

    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.
    alecgibson committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    f91d42c View commit details
    Browse the repository at this point in the history