Skip to content
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

Better byebug integration #2440

Closed
nateberkopec opened this issue Oct 21, 2020 · 5 comments
Closed

Better byebug integration #2440

nateberkopec opened this issue Oct 21, 2020 · 5 comments
Labels

Comments

@nateberkopec
Copy link
Member

Cluster-mode Puma and byebug (default gem in Rails) play poorly together.

Not sure what a good course of action is here.

@nateberkopec
Copy link
Member Author

Unfortunately, I imagine debuggers hold the GVL while they're open, so I'm not sure we can do much.

Maybe we just need to open a PR to Rails to increase worker_timeout (or disable?) in dev.

@nateberkopec
Copy link
Member Author

I wonder if we could detect whether or not a debugger session has begun.

@nateberkopec
Copy link
Member Author

Other options here:

  1. If we go into a debugger session, send something on the pipe that says "stop checking me, I'll be back later" and don't ever terminate that worker
  2. Find a way to make the worker checkin pass even during a debugger session

@cjlarose
Copy link
Member

cjlarose commented Oct 23, 2020

I'm not sure the linked SO post is related. I use pry and pry-remote regularly on Rails apps running under cluster-mode puma that I help maintain and I don't encounter timeouts (worker_timeout is the default value of 60 seconds). I think pry only hijacks the currently-executing thread, so it doesn't affect the worker's check-in/heartbeat thread. I'm not sure what problem the OP in the SO post was encountering, but I don't think their experience is typical.

That said, I think byebug is different in that it'll pause the execution of all Ruby threads of the process, so I think the title of the issue might still be correct. Have you seen reports of byebug specifically causing a problem for people? There might be a better issue to link instead.

@nateberkopec
Copy link
Member Author

Just took another look here. I'm 95% sure this is because byebug is using a c-ext to do what it does, and that c-ext does not unlock the GVL.

C-extensions hold the GVL unless explicitly unlocked, and other threads will not pre-empt a thread inside a C-extension, holding the GVL.

This is why you can't repro the issue with pry, because pry is written completely in Ruby.

I believe rails/rails#40503 is the best workaround for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants