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

Improved forking implementation #364

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bestie
Copy link
Contributor

@bestie bestie commented Feb 5, 2024

  • Set config value forks instead of parallel_workers
  • Supervisor process forks worker n processes
  • Supervisor terminates workers when it is stopped
  • Workers monitor supervisor and terminate themselves if supervisor exits to prevent zombie processes
  • Supervisor runs pre-fork hook before forking
  • Workers run post-fork hook immediately after forking

@dasch
Copy link
Contributor

dasch commented Feb 7, 2024

Would this replace the existing parallel workers setup? If not, why have two?

@bestie
Copy link
Contributor Author

bestie commented Feb 7, 2024

I think it should replace it, but for now I went with the lowest friction option of complete separate feature.

There are differences in behavior on error and when processes die unexpectedly, so I was imagining we could deprecate current 'parallel workers' implementation and remove it in 3.x. If we're up for messing with an 'experimental' in a minor release I do not object.

@dasch
Copy link
Contributor

dasch commented Feb 7, 2024

Probably up to the owning team, but it should at least be documented that they're two implementations of the same feature, one of them experimental (for now).

pids.each do |pid|
unless worker_running?(pid)
$stdout.puts("A forker worker has exited. Shuttin' it down ...")
stop
Copy link
Contributor

@HeyNonster HeyNonster Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we killing the ForkingRunner here and all of its children if one child exits? Maybe I'm following that incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would unexpected for this to happen, so rather than try to recover from a potentially bad state the whole thing shuts down so Kubernetes can bring up a new replica.

I'm not against trying to recover and replace a lost worker process but that is quite a bit more complex.

* Set config value `forks` instead of `parallel_workers`
* Supervisor process forks worker `n` processes
* Supervisor terminates workers when it is stopped
* Workers monitor supervisor and terminate themselves if supervisor
  exits to prevent zombie processes
* Supervisor runs pre-fork hook before forking
* Workers run post-fork hook immediately after forking
@bestie bestie changed the title New forking implementation (first draft) Improved forking implementation May 1, 2024
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

Successfully merging this pull request may close these issues.

3 participants