Skip to content
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

Ensure that firestore-counter only writes to max 100 documents inside a single transaction #64

Closed
laurenzlong opened this issue Oct 21, 2019 · 2 comments
Assignees

Comments

@laurenzlong
Copy link
Contributor

laurenzlong commented Oct 21, 2019

[READ] Step 1: Are you in the right place?

Issues filed here should be about a feature request for a specific extension in this repository. To file a feature request that affects multiple extensions or the Firebase Extensions platform, please reach out to
Firebase support directly.

[REQUIRED] Step 2: Extension name: firestore-counter

Currently, in the worst case, firestore-counter will act on 499 documents at once since that's the shard limit. (https://github.com/firebase/extensions/blob/master/firestore-counter/functions/src/worker.ts#L32). This is not recommended by the Firestore team. A transaction will have decreased performance if it writes/deletes more than 100 documents inside a transaction.

The code needs to be modified to ensure no more than 100 documents are touched inside a single transaction. It might require changing the number of plans: https://github.com/firebase/extensions/blob/master/firestore-counter/functions/src/worker.ts#L186

@laurenzlong laurenzlong changed the title Ensure that firestore-counter only writes to max 100 documetns inside a single transaction Ensure that firestore-counter only writes to max 100 documents inside a single transaction Oct 23, 2019
@lepatryk
Copy link
Contributor

The easiest way to achieve it is to lower the max number of shards to 100.

Here's a PR to do that: #149

@laurenzlong
Copy link
Contributor Author

Thanks!

@Ehesp Ehesp closed this as completed Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants