Skip to content

Deadlock on background thread running query #299

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

Closed
yoavramov opened this issue Sep 20, 2015 · 7 comments
Closed

Deadlock on background thread running query #299

yoavramov opened this issue Sep 20, 2015 · 7 comments

Comments

@yoavramov
Copy link

Hi,

I faced a deadlock on 5 background threads which got stocked on @synchronized(lock) when running parse queries. I didn't run at the same moment all the 5 queries, but since the user hasn't received a response, the user left the page and return it (which cause the query to run once again).

This is not the first time I faced a deadlock in Parse SDK.
I also find out that calling to PFUser.currentUser() can cause a deadlock on main thread because BFTask use semaphore with "wait for ever"
One more deadlock I faced is which accessing a Parse object from the main thread to read one of its properties while a background thread is updating the object from a query result

The two last deadlocks I've mentioned are locking the main thread, therefore the app is freeze and after a short time the OS terminating it.
The first deadlock is only on background thread, so the app isn't freeze, but the user won't receive any data from server.

@nlutsenko
Copy link
Contributor

Hey @yoavramov, thanks for the report!
Any chance you can post the stack trace for this issue?
It's really hard to debug these as the flow you are describing works great, and I suspect it's closely related to your schema/flow of execution.

@parse-github-bot
Copy link

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

@nlutsenko nlutsenko self-assigned this Sep 21, 2015
@yoavramov
Copy link
Author

Those are the stack trace related to Parse API calls.
As you can see, the only thing i've done it accessing PFUser.currentUser() on the main thread. On the other 2 thread which are locked on the same point, there's not calls from my app, it's your thread and your calls.

This is just one deadlock I'm facing.
Another deadlock related to accessing to an object property on the main thread, while a background thread is parsing a PFQuery which contains this object, whether if it's one of the query result or have a relationship to one of the query result and fetched by using includeKey on PFQuery.

stack trace
stack trace 2

richardjrossiii added a commit that referenced this issue Sep 23, 2015
By no longer holding a lock while recursing, we allow other threads who may be waiting on the current object to progress before iterating to children of the object, solving some of the deadlocks that we've seen in issues #11, #61, and #299.

This does not necessarily fix the above issues, as we probably still have similar deadlocks elsewhere in the codebase.

cc @grantland
richardjrossiii added a commit that referenced this issue Sep 23, 2015
By no longer holding a lock while recursing, we allow other threads who may be waiting on the current object to progress before iterating to children of the object, solving some of the deadlocks that we've seen in issues #11, #61, and #299.

This does not necessarily fix the above issues, as we probably still have similar deadlocks elsewhere in the codebase.

cc @grantland
@richardjrossiii
Copy link
Contributor

Hey guys, just pushed out a new branch today, richardross.collectdirtychildren.deadlock, that should fix at least one of the deadlocks that we've seen in this thread.

If you would like to test with that branch and see if it helps with your deadlocks, please feel free, and post stack traces if you still have deadlocks. Let's get these bugs squashed!

richardjrossiii added a commit that referenced this issue Sep 23, 2015
By no longer holding a lock while recursing, we allow other threads who may be waiting on the current object to progress before iterating to children of the object, solving some of the deadlocks that we've seen in issues #11, #61, and #299.

This does not necessarily fix the above issues, as we probably still have similar deadlocks elsewhere in the codebase.

cc @grantland
@parse-github-bot
Copy link

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

@yoavramov
Copy link
Author

Here another stack trace which cause a deadlock.
(This version use the branch with the fix you've mentioned above)

stack trace1
stack trace2

@parse-github-bot
Copy link

We are closing this issue due to another 7 days of inactivity. If you have additional information to help pinpoint this issue as an SDK bug, please reopen it with the additional information.Thank you for your feedback.

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

5 participants