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

Fully unload add-ons under a mutex when shutting down #2970

Merged

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Dec 10, 2024

Motivation

While investigating the possible add-on duplication bug in Tapioca, I noticed two small issues with our add-on deactivation:

  1. The major one is not running under a mutex. This is problematic because if an add-on performs IO operations during deactivation (like the Rails add-on shutting down its runtime server) or if it simply takes too long, threads may be switched in the middle of the shutdown request. That means that, in theory, we can receive a shutdown request, switch threads and then process an exit request before the shutdown is finished - which is incorrect and may lead to hanging child processes
  2. The much minor issues is that we were simply not clearing the add-on list. In theory, this shouldn't matter, since the process fully exits, but I think it's good form to fully cleanup before quitting

Implementation

Moved the entire shutdown request under the mutex to avoid any race conditions between shutdown and exit.

Create a convenience method to unload all add-ons and started using that.

Copy link
Member Author

vinistock commented Dec 10, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock added server This pull request should be included in the server gem's release notes bugfix This PR will fix an existing bug labels Dec 10, 2024 — with Graphite App
@vinistock vinistock force-pushed the 12-10-fully_unload_add-ons_under_a_mutex_when_shutting_down branch from 5c300ba to 9c9799f Compare December 10, 2024 21:27
@vinistock vinistock marked this pull request as ready for review December 10, 2024 21:29
@vinistock vinistock requested a review from a team as a code owner December 10, 2024 21:29
@vinistock vinistock merged commit fface59 into main Dec 16, 2024
36 checks passed
@vinistock vinistock deleted the 12-10-fully_unload_add-ons_under_a_mutex_when_shutting_down branch December 16, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants