Skip to content

Retrying transactions with backoff #2063

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 13 commits into from
Aug 13, 2019
Merged

Retrying transactions with backoff #2063

merged 13 commits into from
Aug 13, 2019

Conversation

thebrianchen
Copy link

I was trying to come up with ways to skip the timeouts in integration tests, and though I'm not a fan overwriting the AsyncQueue instead of initializing it, I couldn't find another way, since we instantiate Firestore through the public API in tests (link). The downside to doing this that the readonly property of _queue in the internal Firestore has to be removed, but there aren't many places where _queue is accessed or set.

Another option to consider is mocking out setTimeout within the scope of the runTransaction call, but that seems more hacky.

@mikelehen mikelehen assigned thebrianchen and unassigned wilhuff Aug 8, 2019
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Yup. skipDelaysForTimerId() LGTM!

@thebrianchen thebrianchen requested a review from mikelehen August 12, 2019 02:38
@thebrianchen thebrianchen removed the request for review from wilhuff August 12, 2019 02:38
@thebrianchen
Copy link
Author

@mikelehen I've updated the web version to also use the stubbed exponential backoff in tests to match the Android version.

@mikelehen
Copy link
Contributor

Per my Android feedback, I'd prefer go back to the skipDelaysForTimerId() approach. I'm also in favor of trying to bring JS more closely inline with Android (and probably iOS). But we can defer that discussion until the iOS port is further along.

@mikelehen mikelehen assigned thebrianchen and unassigned mikelehen Aug 12, 2019
@mikelehen
Copy link
Contributor

Random note relating to unifying the platforms and whether to change web to run the transaction logic on the AsyncQueue or not: Right now, transactions will likely continue to retry even after you call shutdown() on the client. If we hooked the transaction code into the AsyncQueue, that would automatically be fixed.

@thebrianchen thebrianchen requested a review from mikelehen August 13, 2019 18:22
@thebrianchen thebrianchen removed their assignment Aug 13, 2019
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Nice! Glad you got this working. The AsyncQueue stuff is tricky, but I think it's good to match the other platforms. I have a few nits and an optional cleanup. But in general this is looking good.

@mikelehen mikelehen assigned thebrianchen and unassigned mikelehen Aug 13, 2019
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Ship it!

@thebrianchen thebrianchen merged commit c822e78 into master Aug 13, 2019
@thebrianchen thebrianchen deleted the bc/tx-backoff branch August 13, 2019 23:41
@firebase firebase locked and limited conversation to collaborators Oct 8, 2019
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