-
-
Notifications
You must be signed in to change notification settings - Fork 735
All calls to save() or fetch() on ParseUser and ParseInstallation will freeze if previous call to saveEventually() has failed #827
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
Comments
Currently I have users of my app that can't use it because their installation is in this state : any save or fetch in background never returns. |
@dangtz this looks quite serious. Are you able to pinpoint the exact reason why this behavior is exhibited? |
@flovilmart it seems that there is a deadlock in the code that manage operations queue for persisted singletons like ParseInstallation and ParseUser, because I'm not able to reproduce this issue with a basic ParseObject, even if I pin the object in LDS. |
@dangtz because you're able ton consistently reproduce it, can you perhaps open a failing PR, that exhibit the deadlock? Perhaps plucking a debugger and checking the stack / threads once dead locked can help pinpoint the issue. |
@flovilmart by "failing PR" you mean creating new unit tests in the sdk? |
Yep, I mean a new test that is currently failing without a fix.
Most probably, adding a mock would be the way to go as we never run edge to edge tests with a live server for this SDK IIUC. |
- The eventually queue should be cleared at each test execution but Parse.getEventuallyQueue().clear() crashes, that's why line 1585 is commented
…produce exactly issue parse-community#827
@flovilmart I'm not able to reproduce this issue with unit tests #831 |
Ok, so that means that the full app is in an invalid state which is quite bad as we have a persistent issue. |
Yes, and now I have to take my time to prepare a publication for my users to explain them the only solution to the problem is to reinstall the app and then lost all their local data (pinned in localdatastore) :-( |
Nah, we can do better I believe no? If we find the soUrce of the deadlock, we can ensure that at next restart everything is back on track |
That's what I was trying to do. The exact async method that doesn't return is this one : |
@flovilmart here is a standalone app showing the issue : https://github.com/DanGTZ/Parse-Android-SDK-Test The tests testSaveEventuallyInstallation and testSaveEventuallyUser passe the first time they are launched, then subsequent launches will freeze on the first save() Expects a local parse-server with application id "parse_app_id" and client key "parse_client_key". |
@Jawnnypoo and @rogerhu , is that something you guys you could have a look at? |
Here is the cloud code that is needed for this test :
|
Thanks for the repro -- I see the same thing. Note I had to change your code to be |
@rogerhu sorry forgot to add this line before the function : |
More info, once the saveEventually has failed :
I guess something wrong is persisted in LDS when saveEventually fails. Then after relaunch, the wrong data is loaded from LDS and make any subsequent save deadlocking. If the app is not relaunched, user logs in and save the object, the wrong data is removed from LDS, due to successful saving, and the problem never occurs. I think this is the most likely hypothesis. |
…Object.java:L1604 occurs
This issue occurs after loading invalid data from the cache at step 5. To prevent loading invalid data at startup, clear the ParseUser or ParseInstallation disk cache just after the saveEventually() has failed (step 4). To do so, you can use this gist : https://gist.github.com/DanGTZ/7c95d6fc0bb95d3d7433ab7dc309eeac I've also updated my test app so you can see the impact of clearing cache : https://github.com/DanGTZ/Parse-Android-SDK-Test |
* Improved test for parse-community#827 : - Generalize to any server error that is different to CONNECTION_FAILED (not only INVALID_SESSION_TOKEN) - Added isDirty() checks - fixed test tearDown
* - Added a failing test for #827 - The eventually queue should be cleared at each test execution but Parse.getEventuallyQueue().clear() crashes, that's why line 1585 is commented * Removed unused imports * Fixed ParseUserTest.testSaveEventuallyWhenSessionIsInvalid() so it reproduce exactly issue #827 * Fixed server response mocking in ParseUserTest.testSaveEventuallyWhenSessionIsInvalid() * Failing test for #827 fails when the deadlock at ParseObject.java:L1604 occurs * * Suggestion of fix for #827 * Improved test for #827 : - Generalize to any server error that is different to CONNECTION_FAILED (not only INVALID_SESSION_TOKEN) - Added isDirty() checks - fixed test tearDown * Working fix suggestion for #827
Fixed with #831 |
After ParseUser.saveEventually() or ParseInstallation.saveEventually() has failed, the sdk seems to be in a corrupted state as all subsequent calls to save() or fetch() on ParseUser and ParseInstallation will freeze. Restarting the app or the device will not solve the issue and only a re-installation of the app allows to save/fetch ParseUser/ParseInstallation again.
This issue occurs with any version of parse-server and any version of Parse-SDK-Android.
Steps to reproduce the issue on ParseUser (same for ParseInstallation)
Note that terminating the app then relaunching it will not change anything : any call to user.save() will freeze (as user.saveInBackground() never completes).
Parse initialization code used
Standalone app showing the issue
https://github.com/DanGTZ/Parse-Android-SDK-Test
The tests testSaveEventuallyInstallation and testSaveEventuallyUser passe the first time they are launched, then subsequent launches will freeze on the first save()
https://github.com/DanGTZ/Parse-Android-SDK-Test/blob/master/app/src/androidTest/java/com/perfexpert/parsetest/ParseSaveEventuallyTest.java
Workaround
This issue occurs after loading invalid data from the cache at step 5. To prevent loading invalid data at startup, clear the ParseUser or ParseInstallation disk cache just after the saveEventually() has failed (step 4). To do so, you can use this gist : https://gist.github.com/DanGTZ/7c95d6fc0bb95d3d7433ab7dc309eeac
The text was updated successfully, but these errors were encountered: