-
Notifications
You must be signed in to change notification settings - Fork 79
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
Allow to disable bulkheads in a given thread #562
Conversation
ad785c1
to
8610008
Compare
Have you seen #560 ? |
Yes. From what I understand, that patch is helpful if you implement a custom async-friendly Semian adapter like in @kovyrin's example. That's the best path; however it's worth implementing a custom adapter only when you know that async is going to stay in the app for the long term. Meanwhile, I see benefits of having a shortcut like |
thread.thread_variable_get(THREAD_BULKHEAD_DISABLED_VAR) | ||
end | ||
|
||
def disable_bulkheads_for_thread(thread) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect threads other than current to be passed in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally don't. I've decided on that API to make it clear to the user that it disables it on a specific thread, not all threads.
I could also make it disable_bulkheads_for_current_thread
but that seemed more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this 👍🏻
I don't know what to think about this. The point of bulkheads is to ensure all your capacity won't be stuck on a single slow resource. So it seems to me what you want to do is to only acquire a single ticket for all your fibers, not just disable bulkheads. But it's been a long time since I worked on all this, so I don't have any string opinion. |
This is not a proper solution, it's more of an escape hatch to disable bulkheads to experiment with concurrency in an app that's using non-thread-safe bulkheads feature of Semian.
Once we run those experiments, we could work on proper thread and fiber-safe bulkheading. |
The default Semian's bulkhead implementation being not fiber safe makes it hard to experiment with concurrency in a larger app which relies on that implementation.
I'd like to introduce
Semian.disable_bulkheads_for_thread
which will let me experiment with async IO in an app that's using Semian's non-fiber-safe bulkheads.Example:
Without something like this, the 2nd fiber that tries to hit Activerecord fails with: