Rework startup/upgrade/bootstrap process to prune modules before core upgrade#7419
Open
labkey-adam wants to merge 3 commits intodevelopfrom
Open
Rework startup/upgrade/bootstrap process to prune modules before core upgrade#7419labkey-adam wants to merge 3 commits intodevelopfrom
labkey-adam wants to merge 3 commits intodevelopfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
Adding SNPRC modules to the TeamCity PostgreSQL distributions resulted in memory leaks since their SND dependency is not yet present.
Currently, modules are removed due to missing dependencies after the core module is upgraded. The removed modules show up as leaked, since several code paths end up holding onto them. For example, core
bootstrap()creates key containers (/, /home, /shared), which causes us to enumerate the active modules, which loads file-based webparts, which creates file watcher listeners that hold onto their owning modules. While webparts are the culprit here, it's likely that other resources could cause similar leaks.My solution is to rework the startup/upgrade/bootstrap process to prune modules with missing dependencies before core upgrade occurs. So now we prune for database compatibility and then immediately prune for module dependencies. As a result, core upgrade and
init()implementations that enumerate active modules work on the pruned list. A side benefit is that we log messages about all pruned modules (regardless of reason) together. Module initialization still happens after core upgrade, and any module that fails initialization still gets pruned along with its dependents. A module leak will likely happen in this case, but I think it's rare for init() to throw, plus it's always treated as a module startup error.I considered initializing all modules before core upgrade, which is appealing, in theory. However, that would have meant any operation that touches the database (role registration, property retrieval & update, etc.) would need to move from init() into
startup()since core schemas could be empty or in a bad state when init() is invoked. This would have changed our rules and forced updates to 25+ modules that we manage (plus potentially others that we don't).Related Pull Requests