Skip to content

Idempotency: Address TODOs, add Changelog #2270

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
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Unreleased
- [changed] Improved iOS 13 support by addressing a change in Mobile Safari
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably more important to tie this to observed user behavior and link to the details if someone is really curious.

Fixed a crash on iOS 13 that could happen if Firestore was used in a tab in the background (#2232).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to say:

"Fixed a crash on iOS 13 that occurred when persistence was enabled in a background tab."

This still points out that it is a persistence-only issue. As for linking to the original issue, we unfortunately don't do this in our public release notes (see https://firebase.google.com/support/release-notes/js), but I added it here in case someone uses our internal release notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, we do link to issues in the iOS release notes (https://firebase.google.com/support/release-notes/ios) so there's definitely precedent for it. I think it would be helpful.

that disabled IndexedDB persistence if the Firestore SDK was used in a
background tab.

# 1.6.0
- [fixed] Fixed a regression that caused queries with nested field filters to
crash the client if the field was not present in the local copy of the
document.

- [feature] Added a `Firestore.onSnapshotsInSync()` method that notifies you
when all your snapshot listeners are in sync with each other.

# 1.5.0
- [feature] Added a `Firestore.waitForPendingWrites()` method that
allows users to wait until all pending writes are acknowledged by the
Expand All @@ -15,8 +22,6 @@
small subset of the documents in a collection.
- [fixed] Fixed a race condition between authenticating and initializing
Firestore that could result in initial writes to the database being dropped.
- [feature] Added a `Firestore.onSnapshotsInSync()` method that notifies you
when all your snapshot listeners are in sync with each other.

# 1.4.10
- [changed] Transactions now perform exponential backoff before retrying.
Expand All @@ -35,7 +40,6 @@
match the query (https://github.com/firebase/firebase-android-sdk/issues/155).

# 1.4.4
>>>>>>> master
- [fixed] Fixed an internal assertion that was triggered when an update
with a `FieldValue.serverTimestamp()` and an update with a
`FieldValue.increment()` were pending for the same document.
Expand Down
11 changes: 0 additions & 11 deletions packages/firestore/src/local/simple_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,6 @@ export class SimpleDb {
);
try {
const transactionFnResult = transactionFn(transaction)
// TODO(schmidt-sebastian): Remove this code/comment or find a way to
// make this a test-only setting.
// Horrible hack to verify that idempotent functions can be run more
// than once.
.next(result => {
if (idempotent && attemptNumber === 1) {
class DOMException {}
throw new DOMException();
}
return result;
})
.catch(error => {
// Abort the transaction if there was an error.
transaction.abort(error);
Expand Down
97 changes: 47 additions & 50 deletions packages/firestore/test/unit/local/local_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,7 @@ function genericLocalStoreTests(
]);
});

// TODO(schmidt-sebastian): This test makes idempotency testing harder.
// Comment back in when done with the idempotent migration.
// eslint-disable-next-line no-restricted-properties
it.skip('reads all documents for initial collection queries', () => {
it('reads all documents for initial collection queries', () => {
const firstQuery = Query.atPath(path('foo'));
const secondQuery = Query.atPath(path('foo')).addFilter(
filter('matches', '==', true)
Expand Down Expand Up @@ -1483,55 +1480,55 @@ function genericLocalStoreTests(
);
});

// TODO(schmidt-sebastian): This test makes idempotency testing harder.
// Comment back in when done with the idempotent migration.
// (queryEngine instanceof IndexFreeQueryEngine && !gcIsEager ? it : it.skip)(
// eslint-disable-next-line no-restricted-properties
it.skip('uses target mapping to execute queries', () => {
// This test verifies that once a target mapping has been written, only
// documents that match the query are read from the RemoteDocumentCache.
(queryEngine instanceof IndexFreeQueryEngine && !gcIsEager ? it : it.skip)(
'uses target mapping to execute queries',
() => {
// This test verifies that once a target mapping has been written, only
// documents that match the query are read from the RemoteDocumentCache.

const query = Query.atPath(path('foo')).addFilter(
filter('matches', '==', true)
);
return (
expectLocalStore()
.afterAllocatingQuery(query)
.toReturnTargetId(2)
.after(setMutation('foo/a', { matches: true }))
.after(setMutation('foo/b', { matches: true }))
.after(setMutation('foo/ignored', { matches: false }))
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterExecutingQuery(query)
// Execute the query, but note that we read all existing documents
// from the RemoteDocumentCache since we do not yet have target
// mapping.
.toHaveRead({ documentsByQuery: 2 })
.after(
docAddedRemoteEvent(
[
doc('foo/a', 10, { matches: true }),
doc('foo/b', 10, { matches: true })
],
[2],
[]
const query = Query.atPath(path('foo')).addFilter(
filter('matches', '==', true)
);
return (
expectLocalStore()
.afterAllocatingQuery(query)
.toReturnTargetId(2)
.after(setMutation('foo/a', { matches: true }))
.after(setMutation('foo/b', { matches: true }))
.after(setMutation('foo/ignored', { matches: false }))
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterAcknowledgingMutation({ documentVersion: 10 })
.afterExecutingQuery(query)
// Execute the query, but note that we read all existing documents
// from the RemoteDocumentCache since we do not yet have target
// mapping.
.toHaveRead({ documentsByQuery: 2 })
.after(
docAddedRemoteEvent(
[
doc('foo/a', 10, { matches: true }),
doc('foo/b', 10, { matches: true })
],
[2],
[]
)
)
)
.after(
noChangeEvent(/* targetId= */ 2, /* snapshotVersion= */ 10, 'foo')
)
.after(localViewChanges(2, /* fromCache= */ false, {}))
.afterExecutingQuery(query)
.toHaveRead({ documentsByKey: 2, documentsByQuery: 0 })
.toReturnChanged(
doc('foo/a', 10, { matches: true }),
doc('foo/b', 10, { matches: true })
)
.finish()
);
});
.after(
noChangeEvent(/* targetId= */ 2, /* snapshotVersion= */ 10, 'foo')
)
.after(localViewChanges(2, /* fromCache= */ false, {}))
.afterExecutingQuery(query)
.toHaveRead({ documentsByKey: 2, documentsByQuery: 0 })
.toReturnChanged(
doc('foo/a', 10, { matches: true }),
doc('foo/b', 10, { matches: true })
)
.finish()
);
}
);

it('last limbo free snapshot is advanced during view processing', async () => {
// This test verifies that the `lastLimboFreeSnapshot` version for QueryData
Expand Down