Skip to content

Update remote_documents table to add dedicated parent_path column #3173

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

Closed
wants to merge 10 commits into from

Conversation

schmidt-sebastian
Copy link
Contributor

The current table design reads all documents from subcollections as we scan a collection path. This makes it impossible to fetch the first N documents by using "Limit N", which we would like to do for the Index backfill.

@schmidt-sebastian
Copy link
Contributor Author

I am working on performance data but don't have anything for now.

 Changes to be committed:
Copy link
Contributor

@wu-hui wu-hui left a comment

Choose a reason for hiding this comment

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

Looks good.

How was the performance of the migration?

path,
+ "(collection_path, document_id, read_time_seconds, read_time_nanos, contents) "
+ "VALUES (?, ?, ?, ?, ?)",
collectionForKey(documentKey),
Copy link
Contributor

Choose a reason for hiding this comment

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

These are repeated enough that I think we can add them to DocumentKey, like key.collection() and key.documentId() ?

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

@@ -571,6 +571,35 @@ public void rewritesCanonicalIds() {
});
}

@Test
public void rewritesDocumentKeys() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to also have a test where the number of documents to migrate exceeds the batch size, to make sure batching works.

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

@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui Nov 29, 2021
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 29, 2021

Coverage Report

Affected SDKs

  • firebase-firestore

    SDK overall coverage changed from 45.28% (d0048fd) to 45.32% (04e8289c) by +0.04%.

    Filename Base (d0048fd) Head (04e8289c) Diff
    AsyncQueue.java 78.11% 77.11% -1.00%
    DeleteMutation.java 95.00% 90.00% -5.00%
    SQLiteRemoteDocumentCache.java 96.00% 95.70% -0.30%
    SQLiteSchema.java 96.27% 96.67% +0.40%
    SetMutation.java 97.14% 94.29% -2.86%

Test Logs

Notes

HTML coverage reports can be produced locally with ./gradlew <product>:checkCoverage.
Report files are located at <product-build-dir>/reports/jacoco/.

Head commit (04e8289c) is created by Prow via merging commits: d0048fd 0f93b23.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 29, 2021

Binary Size Report

Affected SDKs

  • firebase-firestore

    Type Base (d0048fd) Head (04e8289c) Diff
    aar 1.23 MB 1.23 MB +214 B (+0.0%)
    apk (release) 3.33 MB 3.33 MB +176 B (+0.0%)

Test Logs

Notes

Head commit (04e8289c) is created by Prow via merging commits: d0048fd 0f93b23.

@schmidt-sebastian schmidt-sebastian changed the title Migrate remote_documents table to use dedicated collection_path column Update remote_documents table to add dedicated parent_path column Nov 29, 2021
@schmidt-sebastian
Copy link
Contributor Author

I had to update the PR to add a dedicated parent_path column but keep the other column as is. This allows schema downgrades, as older clients expect path to exist. The small additional benefit that this brings is that the schema migration is now a lot less performance intensive and should be okay to ship as we have done in the past. I will provide performance data by the end of the day.

@schmidt-sebastian
Copy link
Contributor Author

FYI:

Migration from version 12 to 13 took 408 milliseconds

This is for 1775 docs.

@google-oss-bot
Copy link
Contributor

@schmidt-sebastian: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
device-check-changed 0f93b23 link /test device-check-changed

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@schmidt-sebastian
Copy link
Contributor Author

FYI there is a new version of this PR: https://github.com/firebase/firebase-android-sdk/pull/3192/files

@firebase firebase locked and limited conversation to collaborators Dec 31, 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