Skip to content

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

Merged
merged 3 commits into from
Aug 9, 2019
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Aug 8, 2019

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.

// 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).
Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha. Nice! LGTM.

Copy link
Contributor

@wilhuff wilhuff left a 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
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Aug 9, 2019
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Aug 9, 2019
@schmidt-sebastian
Copy link
Contributor Author

/test device-check-changed

@schmidt-sebastian schmidt-sebastian merged commit a96334f into master Aug 9, 2019
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/nodoc branch August 27, 2019 23:45
@firebase firebase locked and limited conversation to collaborators Oct 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants