-
Notifications
You must be signed in to change notification settings - Fork 428
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
[Question] How to handle timeout in transaction? #1042
Comments
It is more typical to treat transaction as a single unit, and handle timeouts on the transaction itself, then handling timeouts inside a transaction, as your example shows.
|
@wu-hui Thank you for the reply! The main issue is that awaiting SetAsync will never finish when the device is offline, so we need to handle the timeout directly at the SetAsync. Another issue is when the first SetAsync is successful, but the second one fails with a timeout, no roll-back is happening. This results in 50% of the transaction being saved in Firestore while the other 50% isn't saved. |
The transaction has an exponential logic, which leads to pretty long timeout, the And the second issue seems to suggest the transaction failed to satisfy its atomic property, which is pretty bad. Do you observe the partial update after your transaction fails, or is it from inside the transaction? |
@wu-hui I'm testing the second issue by throwing a TimeoutException after the first SetAsync. This is the normal behavior when using UniTask's Timeout function. |
Thanks..I'll give it a try myself. If this is true, then this is something we need to fix. |
Ah, my bad. I just noticed in your code, you are using Calling See: https://firebase.google.com/docs/reference/unity/class/firebase/firestore/transaction |
Closing this issue because I am confident of the cause, feel free to comment on it if switching to using transaction object for writes does not work. |
@wu-hui Doing the following still results in the first Set being saved in the database without any rollback:
Did I miss something? |
Assigning this ticket to @wu-hui for investigation |
Hi @Nyankoo This is strange, I just tried myself and it works fine ( the mutation is not saved). I would need 2 things to be able to move forward:
|
|
@dconeybe Thank you for the update, looking forward to it! |
Update: I have a fix but it unfortunately won't make it into the next release of the Firebase Unity SDK. It will, however, make it into the release after that. Also, there is a relatively easy workaround in the meantime. The bug is in the overload of So the workaround is to adapt your code to call For example, your code above could be changed to the following:
And just make sure to explicitly call I will update this issue once my fix is submitted and when it gets released. |
Update: The fix has been submitted and will be included in the next release of the Firebase Unity SDK. I can't promise a concrete release date, but I'd expect some time in the next 2-3 weeks. In the meantime, I recommend to continue using the workaround I provided in the previous comment. I'll close this ticket for now since there are no further actions from our end. Thank you for reporting this and working together on the investigation. Note to Googlers: The fix is cl/375130076 (release notes: cl/375712637). I also created b/189214152 to ensure that we improve the test coverage of |
Update: The fix was released with the Unity SDK 8.0.0 on June 17, 2021. https://firebase.google.com/support/release-notes/unity#version_800_-_june_17_2021 |
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the question here:
How do we handle timeout exceptions in a transaction? Please see this example:
The text was updated successfully, but these errors were encountered: