-
Notifications
You must be signed in to change notification settings - Fork 13
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
mapTasks_ does not work #2
Comments
@spl Thanks for the report! Also, I see your point about nested How is this for a solution: Each time we spawn a thread within a task group, we remember the I'm not sure exactly how this will work in the code, but we do need some way for the blocked worker thread to make progress in these situations. I'll create a test to reproduce the deadlock and then see what I can do. Thanks for trying |
As for |
To further clarify the deadlock-resolving solution: When calling This way we can commandeer execution to avoid the delay, while not upsetting anyone depending on the result via the task group. |
@jwiegley Thanks for the response. I don't have time to answer fully right now, but there are a couple of things I wanted to mention. I did see the code containing I ran the new |
@spl Ok, I really want to get to the bottom of this, so anything I can do to help, let me know. I tried implementing the deadlock avoidance that I described above, but it is not possible: At the point where the deadlock happens, I don't have access to IO, only STM. So what about this for an alternate solution: Waiting, within an active task, on a task spawned from that thread throws an exception, with a suggestion to use a secondary task group? |
I feel I'm getting a bit lost. There are two independent issues, right?
To keep the discussion focused, I suggest creating a new GitHub issue for the second issue. I think it's much more difficult to resolve. At this point, I would add documentation that functions such as As for the first issue, were you able to reproduce my problem? If not, I'll try to make a small test case. It should be easy to do using my app+database setup, but I can try to do it without the database, perhaps with a That said, time to respond to some of your comments:
I do think it is unexpected to have the
This sounds like some form of deadlock detection. How certain can you be that the exception doesn't get thrown for a “legitimate” wait? |
My apologies for confusing this ticket. I'll continue discussing |
As for |
@spl After thinking about it a lot more, I think that |
That makes sense, and it would be good to document the Sorry I haven't gotten back to you with the test case. I've been rather busy lately. I've got a deadline next weekend, so I'm busy this weekend as well. Do you still want the test case for |
@spl Whenever you have the time, I'd really like to know what's going on. Thanks! |
This is a great library, I'd love if this one got fixed. Maybe I can help somehow? |
@Alvare That would be great! If you could write some tests to demonstrate the exact problem, it shouldn't be too hard to find the issue and fix it. Unrelated, by Simon Marlow has pointed out a potential race condition that simply can't be fixed -- but we should have tests to demonstrate it, at the very last as documentation. For example, if you have a task group with 1 slot, and a task A that manually depends on B (using an MVar, instead of the dependency logic in async-pool), and A gets started first by the scheduler, we'll deadlock without detection. The answer in this case is to make use of the dependency graph in async-pool itself, but it does raise the point that manually using blocking constructions can lead to undetected deadlocks. This doesn't happen with regular async, because every thread is allowed to start right away. |
@jwiegley well that's easy: https://gist.github.com/alvare/67c5717affe6bba891f3 Replace |
Is this problem with
|
It looks like the latest version on Github doesn't have this bug anymore (at least the example above definitely works) but I'm not sure that other functions are not buggy. |
|
What's the status of the |
Sorry about the vague title. I haven't looked into the cause, but I thought it was significant enough to report.
I have the following code:
This was the first time I tried
async-pool
, so when I ran it, I was quite surprised that thetasks
did not run. I swapped inmapTasks
formapTasks_
:And the
tasks
ran just fine.Since the problem seems to be pretty clearly due to
mapTasks_
, I hope it's an easy fix for you. Otherwise, if you need a test case or something, let me know.The text was updated successfully, but these errors were encountered: