Don't nest Async primitives inside plain Ruby fibers#5479
Don't nest Async primitives inside plain Ruby fibers#5479
Conversation
|
Sad, it seems like the test suite hangs now... |
b04fa42 to
983d1fb
Compare
|
Ok, I think the problem was that Fiber / Task nesting. I reworked it so that each pass over the set of pending dataloader fibers spins up a new job. This avoids any mixing between Async primitives and plain Ruby Fibers. It messed up some of the fiber counting tests though -- I'll sort them out in the morning. @iyotov-havelock, could you try this branch in your app's test suite and development? You can bundle it with: gem "graphql", github: "rmosolgo/graphql-ruby", ref: "async-dataloader-deadlock-fix"please let me know how it goes! |
|
Hey @rmosolgo, thanks for checking this issue out. Tested it with my 'real' app in development, sadly there's still an issue there: Tested it with the demo app (https://github.com/iyotov-havelock/async-dataloader-issue), the |
|
I saw that error, too, and assumed that GraphQL was "working," since it called code as expected. Inspecting the dataset, I see that it was passed the right values: My hunch is that Async + Sequel aren't playing nice here ... but do you have a reason to think that AsyncDataloader in particular is the cause of the issue? Could you please share the full stack trace (NOT a screenshot) from the error in your application? Maybe some lines there will be a clue. Also, if you can modify the replication app so that it deadlocks on this branch, I'd be happy to keep debugging on that. UPDATE: I got the example to run successfully by adding the fiber_concurrency extension: diff --git a/config/database.rb b/config/database.rb
index 16f3b03..7ec45a8 100644
--- a/config/database.rb
+++ b/config/database.rb
@@ -1,4 +1,5 @@
require 'sequel'
+Sequel.extension :fiber_concurrency
DB = Sequel.connect(
adapter: 'postgres',Have you tried that extension in your app? I found it by searching randomly around the Sequel repo for the word "Fiber"... With that addition, I get: |
|
@rmosolgo I modified the replication app, check out this commit: To reproduce the issue, do the |
|
Interesting -- a change like that puts |
|
👋 I made time to dig back into this and refactor AsyncDataloader to use Async primitives for execution jobs too. After that, I pulled your updated example and updated the Could you give this branch a try in your app when you get a try please? |
|
(The handoff between sources and execution isn't quite right here yet ...) Edit: I think the problem is that |
Hi, thanks for addressing this. App is working fine with the branch 👍 |
|
Awesome, glad to hear it. Today I'm going to try to address #5462 which I think will also address the failing specs here. But it sounds like migrating all usage from Fiber to Async::Task did the job 🎉 |

Fixes #5463