-
Notifications
You must be signed in to change notification settings - Fork 948
b/72533250: Fix issue with limbo resolutions triggering incorrect manufactured deletes. #1014
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,7 +188,7 @@ describeSpec('Limbo Documents:', [], () => { | |
}); | ||
|
||
// Regression test for b/72533250. | ||
specTest('Limbo documents handle receiving ack and then current', [], () => { | ||
specTest('Limbo resolution handles snapshot before CURRENT', [], () => { | ||
const fullQuery = Query.atPath(path('collection')); | ||
const limitQuery = Query.atPath(path('collection')) | ||
.addFilter(filter('include', '==', true)) | ||
|
@@ -236,10 +236,7 @@ describeSpec('Limbo Documents:', [], () => { | |
.watchAcks(docBQuery) | ||
.watchSends({ affects: [docBQuery] }, docB) | ||
|
||
// TODO(b/72533250): If you uncomment this totally valid watch | ||
// snapshot, then the test fails because the subsequent CURRENT below | ||
// is turned into a delete of docB. | ||
//.watchSnapshots(2000) | ||
.watchSnapshots(2000) | ||
|
||
// Additionally CURRENT the query (should have no effect) | ||
.watchCurrents(docBQuery, 'resume-token-3000') | ||
|
@@ -254,4 +251,72 @@ describeSpec('Limbo Documents:', [], () => { | |
.expectLimboDocs() | ||
); | ||
}); | ||
|
||
// Same as above test, except docB no longer exists so we do not get a | ||
// documentUpdate for it during limbo resolution, so a delete should be | ||
// synthesized. | ||
specTest( | ||
'Limbo resolution handles snapshot before CURRENT [no document update]', | ||
[], | ||
() => { | ||
const fullQuery = Query.atPath(path('collection')); | ||
const limitQuery = Query.atPath(path('collection')) | ||
.addFilter(filter('include', '==', true)) | ||
.withLimit(1); | ||
const docA = doc('collection/a', 1000, { key: 'a', include: true }); | ||
const docB = doc('collection/b', 1000, { key: 'b', include: true }); | ||
const docBQuery = Query.atPath(docB.key.path); | ||
return ( | ||
spec() | ||
// No GC so we can keep the cache populated. | ||
.withGCEnabled(false) | ||
|
||
// Full query to populate the cache with docA and docB | ||
.userListens(fullQuery) | ||
.watchAcksFull(fullQuery, 1000, docA, docB) | ||
.expectEvents(fullQuery, { | ||
added: [docA, docB] | ||
}) | ||
.userUnlistens(fullQuery) | ||
|
||
// Perform limit(1) query. | ||
.userListens(limitQuery) | ||
.expectEvents(limitQuery, { | ||
added: [docA], | ||
fromCache: true | ||
}) | ||
.watchAcksFull(limitQuery, 2000, docA) | ||
.expectEvents(limitQuery, { | ||
fromCache: false | ||
}) | ||
|
||
// Edit docA so it no longer matches the query and we pull in docB | ||
// from cache. | ||
.userPatches('collection/a', { include: false }) | ||
.expectEvents(limitQuery, { | ||
removed: [docA], | ||
added: [docB], | ||
fromCache: true | ||
}) | ||
// docB is in limbo since we haven't gotten the watch update to pull | ||
// it in yet. | ||
.expectLimboDocs(docB.key) | ||
|
||
// Suppose docB was actually deleted server-side and so we receive an | ||
// ack, a snapshot, CURRENT, and then another snapshot. This should | ||
// resolve the limbo resolution and docB should disappear. | ||
.watchAcks(docBQuery) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you are not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.watchSnapshots(2000) | ||
.watchCurrents(docBQuery, 'resume-token-3000') | ||
.watchSnapshots(3000) | ||
.expectLimboDocs() | ||
.expectEvents(limitQuery, { removed: [docB], fromCache: false }) | ||
|
||
// Watch catches up to the local write to docA, and broadcasts its | ||
// removal. | ||
.watchSends({ removed: [limitQuery] }, docA) | ||
.watchSnapshots(4000) | ||
); | ||
} | ||
); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Even after a couple second of staring at this, this line matches
335
and hencelimboResolution.receivedDocument = false
is never getting executed.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.
Err.... good catch, fixed. TBH I don't expect the modifiedDocuments or removedDocuments cases to ever be hit, but I included them for completeness.