-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[cloud_firestore] Transactions doesn't seem to work #54
Comments
Thanks for filing this issue. Do you have any suggestions for how to fix it? Do you think this is a bug in the Firestore Android SDK, or in Flutterfire? Can we write an integration test that runs on a single device, or is it necessary to have two devices to trigger the issue? |
I haven't heard mention of transactions not working in iOS or Android. So I assume it's a problem with the Flutter implementation. Regarding tests: I would imagine an integration test on a single device would show the issue. We tested on two physical devices, back in March. In general, it would be a good idea to redo the above tests in their entirety. I've been strapped for time, so I haven't dug into the code to try and figure out whats happening. |
So I retested this. Now it hard crashes the app on the 3 second device:
|
cc @TahaTesser |
having the same hard crash issue , really need this to be working :( any solutions yet ? it only happens when running transaction simultaneously on 2 devices |
I look forward to testing it out |
Issue moved from flutter/flutter#28714
So we're running into some issues with transactions, where
update
statements run without errors, except they don't always update the document in question. Below are a few simple tests.Test 1
Setup
Run on two Android devices, and do a countdown to trigger the code at the same time. The code simulates an artificially long transaction execution, by using
Future.delayed
. One device will useFuture.delayed(Duration(seconds: 3));
and the other will useFuture.delayed(Duration(seconds: 2));
. The default transaction timeout is 5 seconds, so we're well within that.The write operation is incrementing a counter in a single document.
The document looks like so:
{ counter: 0 }
.Results
Device 1 with 2 second transaction console output:
Device 2 with 3 second transaction console output:
Expected document value:
{ counter: 2 }
Actual document value:
{ counter: 1 }
Notes for Test 1:
From observing the logs, device 2 seems to do what it should: It restarts its transaction after it receives the updated document from device 1, but the value of 2 never makes it to the database.
Test 2
Setup
Identical to Test 1, except it's only run on a single device, and a timeout is introduced for the transaction, which is shorter than the execution time for the transaction.
Results
Actual console output:
Expected console output:
Notes for Test 2:
I'm not expecting it to retry the transaction at all, since the
catch
handler has already output the error, meaning the transaction is done.That's all for now. If we dream up some more tests that also cause unexpected results, we'll update this post.
The text was updated successfully, but these errors were encountered: