Skip to content

Schema migration to ensure sentinel rows exist #1911

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 4 commits into from
Oct 5, 2018

Conversation

gsoltis
Copy link

@gsoltis gsoltis commented Oct 4, 2018

Ensures that we have a sequence number written down for each document in the remote document cache. We already have the code to sequence numbers for new documents (via target updates, mutations, and limbo resolutions). However, we have never gone back to make sure existing documents have sequence numbers.

This migration will stamp the highest sequence number observed onto each remote document which does not yet have a sentinel row.

@gsoltis
Copy link
Author

gsoltis commented Oct 4, 2018

Note that I've moved sentinel row encoding and decoding on LevelDbDocumentTargetKey, but I'm not sure that's the best place for it. Let me know if you have suggestions.

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

*/
const LevelDbMigrations::SchemaVersion kSchemaVersion = 3;
const LevelDbMigrations::SchemaVersion kSchemaVersion = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth attempting to keep the migration numbers in sync with the other clients?

https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/local/indexeddb_schema.ts#L39

Copy link
Author

Choose a reason for hiding this comment

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

We would have to implement held-write-acks removal before this, which I don't think is a worthwhile delay.

* Given an encoded sentinel row, return the sequence number.
*/
static model::ListenSequenceNumber DecodeSentinel(
const absl::string_view& slice);
Copy link
Contributor

Choose a reason for hiding this comment

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

absl::string_view is intended to be passed by value (it's just a pointer and a size, which is cheaper to just copy rather than take a reference).

Copy link
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 gsoltis and unassigned wilhuff Oct 5, 2018
@gsoltis gsoltis merged commit 4c86de9 into master Oct 5, 2018
@gsoltis gsoltis deleted the gsoltis/ensure_sequence_number branch October 5, 2018 23:51
@firebase firebase locked and limited conversation to collaborators Oct 26, 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.

3 participants