Skip to content

🥅 Bound getOps() by the current version in timestamp fetches - #731

Draft
alecgibson wants to merge 1 commit into
mainfrom
pass-current-version-to-get-ops
Draft

alecgibson wants to merge 1 commit into
mainfrom
pass-current-version-to-get-ops

Conversation

@alecgibson

@alecgibson alecgibson commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

At the moment, _fetchSnapshotByTimestamp() passes a null to to getOps() when there's no milestone after the timestamp. An empty result then looks the same whether the document hasn't changed since from or its ops have been deleted. So a database adapter, or a wrapper around one, can't flag the missing ops, and we return a blank or stale snapshot with no error.

We've already fetched the current snapshot by this point, so this change passes its v as to. MemoryDB is unaffected, since it already treats a null to as the end of the op log. For sharedb-mongo with getOpsWithoutStrictLinking, it costs one extra query on the {d, v} index.

Now that to is always a number, we also skip getOps() when from >= to. from can exceed to, since milestones are looked up by m.mtime, which a retried submit keeps from its first attempt.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

@coveralls

coveralls commented Sep 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 97.783%. remained the same — pass-current-version-to-get-ops into main

Comment thread lib/backend.js
At the moment, `_fetchSnapshotByTimestamp()` passes a `null` `to` to
`getOps()` when there's no milestone after the timestamp. An empty
result then looks the same whether the document hasn't changed since
`from` or its ops have been deleted. So a database adapter, or a
wrapper around one, can't flag the missing ops, and we return a blank
or stale snapshot with no error.

We've already fetched the current snapshot by this point, so this
change passes its `v` as `to`. `MemoryDB` is unaffected, since it
already treats a `null` `to` as the end of the op log. For
sharedb-mongo with `getOpsWithoutStrictLinking`, it costs one extra
query on the `{d, v}` index.

Now that `to` is always a number, we also skip `getOps()` when
`from >= to`. `from` can exceed `to`, since milestones are looked up
by `m.mtime`, which a retried submit keeps from its first attempt.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@alecgibson
alecgibson force-pushed the pass-current-version-to-get-ops branch from 6060e18 to 587d32f Compare September 30, 2026 18:41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants