-
Notifications
You must be signed in to change notification settings - Fork 617
Don't persist manufactured documents #695
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
Conversation
// If a document update isn't authoritative, make sure we don't apply an old document | ||
// version to the remote cache. We make an exception for SnapshotVersion.MIN which can | ||
// happen for manufactured events (e.g. in the case of a limbo document resolution | ||
// failing). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned on chat, this comment is now misleading. It says we don't write old document versions to the remote cache except we make an exception for SnapshotVersion.MIN (implying we do write it to cache). With your change, this is no longer true.
Perhaps remove "We make an exception ..." from this comment and add a new comment inside your new else-if case that says something like:
This is a manufactured event (since version==SnapshotVersion.NONE), likely as a result of a failed limbo resolution lookup. Rather than write the NoDocument to cache with an invalid version, we just remove whatever might currently be in cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it just as you wrote this comment:) Let me know if the new version is a better description. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha. Nice! LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic LGTM, though I think the placement of the comments is misleading.
|| (authoritativeUpdates.contains(doc.getKey()) && !existingDoc.hasPendingWrites()) | ||
|| doc.getVersion().compareTo(existingDoc.getVersion()) >= 0) { | ||
remoteDocuments.add(doc); | ||
changedDocs.put(key, doc); | ||
// NoDocuments with SnapshotVersion.MIN are used in manufactured events (e.g. in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure make the comment look as if it applies to the block about authoritative updates. Better to put this in the next block (and pull the comment above into this one--above the actions taken).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/test device-check-changed |
This PR makes sure we don't write documents to the RemoteDocumentCache that have a version of 0. This allows us to add an assert in the Index-Free query branch and also makes sure that we don't just persist NoDocuments because of RPC failures.