Skip to content

Run migration to rewrite canonical IDs #7850

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
Apr 7, 2021

Conversation

wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Apr 6, 2021

No description provided.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@google-oss-bot
Copy link

google-oss-bot commented Apr 6, 2021

Coverage Report

Affected SDKs

  • FirebaseFirestore-iOS-FirebaseFirestore.framework

    SDK overall coverage changed from 88.65% (5f6feba) to 88.43% (fd70576) by -0.21%.

    Click to show coverage changes in 11 files.
    Filename Base (5f6feba) Head (fd70576) Diff
    exception.cc 29.27% 65.85% +36.59%
    grpc_nanopb.cc 100.00% 95.45% -4.55%
    leveldb_key.cc 97.60% 96.48% -1.12%
    leveldb_migrations.cc 100.00% 93.40% -6.60%
    mutable_document.cc ? 0.00% ?
    object_value.cc ? 98.02% ?
    serializer.cc 83.68% 84.32% +0.64%
    server_timestamp_util.cc ? 84.85% ?
    task.cc 95.21% 96.41% +1.20%
    value_util.cc ? 88.50% ?
    watch_stream.cc 96.15% 92.31% -3.85%

Test Logs

#include "absl/strings/match.h"
#include "target_data.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100%, but I think we mostly use absolute paths.

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 am going to blame Clion for this one.

StringReader reader{target_it->value()};
auto message = Message<firestore_client_Target>::TryParse(&reader);
if (!reader.ok()) {
HARD_FAIL("Target proto failed to parse: %s", reader.status().ToString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we return a failed status here (and below)? It is probably best not to crash during schema conversion since we load all existing data.

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.

auto query = Query("collection").AddingFilter(Filter("foo", "==", "bar"));
TargetData initial_target_data(query.ToTarget(),
/* target_id= */ 2,
/*sequence_numder*/ 1, QueryPurpose::Listen);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/*sequence_numder*/ 1, QueryPurpose::Listen);
/* sequence_numder= */ 1, QueryPurpose::Listen);

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.


transaction.Delete(it->key());
std::string empty_buffer;
transaction.Put(new_key, empty_buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to write the old data back (empty_buffer sounds suspicious).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This table always has empty value: https://osscs.corp.google.com/firebase-sdk/firebase-ios-sdk/+/master:Firestore/core/src/local/leveldb_target_cache.cc;l=110

It serves as an association between canonical id and target id.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui Apr 7, 2021
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Thank you!


transaction.Delete(it->key());
std::string empty_buffer;
transaction.Put(new_key, empty_buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@wu-hui wu-hui merged commit b089bd9 into mrschmidt/mutabledocuments Apr 7, 2021
@wu-hui wu-hui deleted the wuandy/RewriteCanonicalId branch April 7, 2021 19:58
@firebase firebase locked and limited conversation to collaborators May 8, 2021
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