Skip to content

Implement limbo resolution listen throttling. #1374

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 2 commits into from
Apr 6, 2020

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Mar 19, 2020

This is a port of firebase/firebase-js-sdk#2790 to Android.

The following description was copied from that PR and pasted here for your convenience:

This change was motivated by the following bug report: firebase/firebase-js-sdk#2683. In summary, the issue was that when a large number of documents went into limbo (in this case 15,000 documents) then this would cause 15,000 document listens, which would result in "resource-exhausted" errors. The client would then back off for a bit but would try the listens again, which would again result in "resource-exhausted" errors. And the cycle would continue. Worst of all, the customer was being billed for all of these reads that had no beneficial effects for the clients.

In order to avoid this situation, this PR modifies the limbo resolution logic to "throttle" the limbo resolutions. It does this by allowing at most 100 concurrent limbo resolutions. Limbo resolutions in excess of this limit are queued up and not started until another limbo resolution completes. This fix should avoid the "resource-exhausted" errors and the infinite read loop.

@googlebot googlebot added the cla: yes Override cla label Mar 19, 2020
@dconeybe dconeybe force-pushed the dconeybe/LimboThrottle branch from eab4627 to 9eba6e0 Compare March 19, 2020 16:47
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 19, 2020

Binary Size Report

Affected SDKs

SDKTypeBase (4491f0a)Head (3755464)Diff
firebase-inappmessagingapk (release)?3552426.00? (?)
aar?467515.00? (?)
apk (aggressive)?852137.00? (?)
firebase-common:ktxaar?5965.00? (?)
firebase-inappmessaging:ktxaar?5615.00? (?)
protolite-well-known-typesapk (release)?561089.00? (?)
aar?1203203.00? (?)
apk (aggressive)?122386.00? (?)
firebase-database:ktxaar?6706.00? (?)
firebase-segmentationapk (release)?1667839.00? (?)
aar?35427.00? (?)
apk (aggressive)?1017138.00? (?)
firebase-functions:ktxaar?5844.00? (?)
firebase-storageapk (release)?976604.00? (?)
aar?119257.00? (?)
apk (aggressive)?325645.00? (?)
encoders:firebase-encoders-jsonaar?15335.00? (?)
firebase-commonapk (release)?646638.00? (?)
aar?34517.00? (?)
apk (aggressive)?82958.00? (?)
firebase-firestore:ktxaar?7093.00? (?)
firebase-crashlytics-ndkapk (release)?1937473.00? (?)
aar?598746.00? (?)
apk (aggressive)?1170685.00? (?)
transport:transport-apiaar?6439.00? (?)
transport:transport-backend-cctaar?38343.00? (?)
firebase-inappmessaging-display:ktxaar?22845.00? (?)
firebase-databaseapk (release)?1101861.00? (?)
aar?481593.00? (?)
apk (aggressive)?325611.00? (?)
encoders:firebase-encoders-reflectiveaar?7650.00? (?)
firebase-crashlyticsapk (release)?1354464.00? (?)
aar?401359.00? (?)
apk (aggressive)?583636.00? (?)
transport:transport-runtimeaar?122725.00? (?)
firebase-installationsapk (release)?665549.00? (?)
aar?56405.00? (?)
apk (aggressive)?84608.00? (?)
firebase-config:ktxaar?6162.00? (?)
firebase-dynamic-linksapk (release)?951227.00? (?)
aar?51149.00? (?)
apk (aggressive)?327469.00? (?)
firebase-storage:ktxaar?6143.00? (?)
firebase-installations-interopapk (release)?616109.00? (?)
aar?7509.00? (?)
apk (aggressive)?61724.00? (?)
firebase-componentsapk (release)?25749.00? (?)
aar?34495.00? (?)
apk (aggressive)?10968.00? (?)
firebase-abtapk (release)?746406.00? (?)
aar?35383.00? (?)
apk (aggressive)?85727.00? (?)
firebase-configapk (release)?1143995.00? (?)
aar?214548.00? (?)
apk (aggressive)?395842.00? (?)
firebase-datatransportapk (release)?711393.00? (?)
aar?5041.00? (?)
apk (aggressive)?116366.00? (?)
firebase-dynamic-links:ktxaar?7877.00? (?)
firebase-inappmessaging-displayapk (release)?4818234.00? (?)
aar?166585.00? (?)
apk (aggressive)?1813863.00? (?)
firebase-functionsapk (release)?1178560.00? (?)
aar?25859.00? (?)
apk (aggressive)?393480.00? (?)
firebase-database-collectionapk (release)?912665.00? (?)
aar?34214.00? (?)
apk (aggressive)?313623.00? (?)
firebase-firestoreapk (release)?3139910.00? (?)
aar?1067683.00? (?)
apk (aggressive)?443193.00? (?)
baseapk (release)?8754.00? (?)
apk (aggressive)?10679.00? (?)
Metric Unit: byte

Test Logs

@codecov
Copy link

codecov bot commented Mar 19, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@f0bda45). Click here to learn what that means.
The diff coverage is 95.45%.

Flag Coverage Δ Complexity Δ
#FirebaseFirestore 61.92% <95.45%> (?) 2235 <4> (?)
#FirebaseFirestore_Ktx 41.17% <ø> (?) 0 <ø> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0bda45...3755464. Read the comment docs.

@dconeybe dconeybe force-pushed the dconeybe/LimboThrottle branch from 9eba6e0 to 6caedce Compare March 23, 2020 17:47
@dconeybe
Copy link
Contributor Author

dconeybe commented Apr 3, 2020

/test device-check-changed

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 3, 2020

Coverage Report

Affected SDKs

SDKTypeBase (4491f0a)Head (3755464)Diff
firebase-firestore-ktx?0.41? (?)
Firestore.kt?0.41? (?)
firebase-firestore?0.43? (?)
DocumentRemoveOrBuilder.java?0.00? (?)
Stream.java?1.00? (?)
ArrayContainsFilter.java?1.00? (?)
WatchChangeAggregator.java?0.98? (?)
254 more entries not displayed here ...
Metric Unit: percentage

Test Logs

Notes

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

@dconeybe dconeybe requested a review from wilhuff April 3, 2020 18:04
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, though bring in the changelog entry that results from firebase/firebase-js-sdk#2864 before submitting.

@wilhuff wilhuff assigned dconeybe and unassigned wilhuff Apr 3, 2020
@dconeybe
Copy link
Contributor Author

dconeybe commented Apr 6, 2020

/test smoke-tests

@dconeybe dconeybe merged commit ef455a6 into master Apr 6, 2020
@dconeybe dconeybe deleted the dconeybe/LimboThrottle branch April 6, 2020 13:45
@firebase firebase locked and limited conversation to collaborators May 7, 2020
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.

4 participants