Skip to content

get() reimplementation #3887

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 32 commits into from
Jul 29, 2022
Merged

get() reimplementation #3887

merged 32 commits into from
Jul 29, 2022

Conversation

maneesht
Copy link
Contributor

@maneesht maneesht commented Jul 11, 2022

Fixes the issue first seen on iOS: firebase/firebase-ios-sdk#8286. Essentially, the wrong path in the SyncTree was being updated. Before, regardless of what type of query was being sent, we were always updating the default query path. Now, we add the query to the SyncTree (along with Persistence) by adding an event registration (just like for a listener) and then remove the event registration once the data has come back.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2022

Unit Test Results

401 tests   - 689   399 ✔️  - 675   27s ⏱️ -26s
  27 suites  -   51       2 💤  -   14 
  27 files    -   51       0 ±    0 

Results for commit 2d7b15f. ± Comparison against base commit 310ce36.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 11, 2022

Coverage Report 1

Affected Products

  • firebase-database

    Overall coverage changed from 50.18% (d4fd4a8) to 50.15% (c559af1) by -0.03%.

    FilenameBase (d4fd4a8)Merge (c559af1)Diff
    PersistentConnectionImpl.java17.04%17.07%+0.02%
    Repo.java10.45%10.31%-0.14%
    SyncPoint.java88.79%88.89%+0.10%
    SyncTree.java57.24%57.14%-0.10%
    WriteTree.java76.67%77.22%+0.56%

Test Logs

Notes

  • Commit (c559af1) is created by Prow via merging PR base commit (d4fd4a8) and head commit (2d7b15f).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/mnhsSmJHlu.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 11, 2022

Size Report 1

Affected Products

  • firebase-database

    TypeBase (d4fd4a8)Merge (c559af1)Diff
    aar488 kB489 kB+1.24 kB (+0.3%)
    apk (release)1.15 MB1.15 MB+328 B (+0.0%)

Test Logs

Notes

  • Commit (c559af1) is created by Prow via merging PR base commit (d4fd4a8) and head commit (2d7b15f).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/dI5Ak7cGRY.html

@maneesht maneesht requested a review from jmwski July 19, 2022 15:40
Copy link
Contributor

@jmwski jmwski left a comment

Choose a reason for hiding this comment

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

Reviewed the tests, will review the rest later.

@maneesht maneesht marked this pull request as ready for review July 27, 2022 19:52
Copy link
Contributor

@jmwski jmwski left a comment

Choose a reason for hiding this comment

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

This is great, those skipDedup + skipListenerSetup parameters make this much easier to think about! I'm ready to approve once these comments are addressed.

@jmwski jmwski assigned maneesht and unassigned jmwski Jul 28, 2022
@maneesht maneesht assigned jmwski and unassigned maneesht Jul 29, 2022
Copy link
Contributor

@jmwski jmwski left a comment

Choose a reason for hiding this comment

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

LGTM, did you run ./gradlew :firebase-database:googleJavaFormat?

DatabaseReference parentReadNode = readDb.getReference().child(parentNodeKey);
IntegrationTestHelpers.waitFor(semaphore);
DataSnapshot snapshot = await(parentReadNode.get());
assertEquals(snapshot.child(childNodeKey).getValue(), val);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note, no need to make any changes.

I think in the future for assertions like this we should assert the contents of snapshot as opposed to indexing into it with .child():

assertEquals(MapBuilder.put(childNodeKey, val).build(), snapshot.getValue());

I think in general it's easier to think about "values of references" as on L4765 below. It's also more correct because it tests that unexpected keys don't exist at snapshot.getValue().

Comment on lines +4801 to +4809
FirebaseApp readApp =
appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString());
FirebaseApp writeApp =
appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString());
FirebaseDatabase readDb = FirebaseDatabase.getInstance(readApp);
FirebaseDatabase writeDb = FirebaseDatabase.getInstance(writeApp);
String parentKey = UUID.randomUUID().toString();
DatabaseReference writeRef = writeDb.getReference().child(parentKey);
DatabaseReference child1Ref = readDb.getReference().child(parentKey).child("child1");
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to do this in a separate PR, we could definitely abstract some of this setup into a helper, potentially even a some sort of TestFixture class.

@jmwski jmwski assigned maneesht and unassigned jmwski Jul 29, 2022
@maneesht
Copy link
Contributor Author

LGTM, did you run ./gradlew :firebase-database:googleJavaFormat?

Yes. Tests fail otherwise

@jmwski jmwski assigned jmwski and unassigned maneesht Jul 29, 2022
@jmwski jmwski assigned maneesht and unassigned jmwski Jul 29, 2022
@maneesht maneesht merged commit 884e537 into master Jul 29, 2022
@maneesht maneesht deleted the mtewani/fix-get-cache branch July 29, 2022 21:30
lfkellogg pushed a commit that referenced this pull request Aug 5, 2022
Fixed `get()` issue where wrong cache paths were being updated in the SyncTree.

Co-authored-by: Jan Wyszynski <[email protected]>
@firebase firebase locked and limited conversation to collaborators Aug 29, 2022
new MapBuilder().put("child1", "test1").put("child2", "test2").build();
try {
await(writeRef.setValue(expected));
ReadFuture.untilEquals(readRef, expected).timedGet();
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this test supposed to install a listener with a timeout and validate that we don't get two events in some window?

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 believe so

* that location, listen would be called twice on the same query. skipDedup allows us
* to skip this deduping process altogether.
*/
if (skipDedup) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are leaking the tag created inside keepSynced(true) in Repo.getValue because we never hit L790.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants