[Koha-bugs] [Bug 31074] Cached plugin code is used in Koha even after changes to plugin (install/upgrade/uninstall)
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Jun 19 08:41:14 CEST 2023
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31074
--- Comment #19 from David Cook <dcook at prosentient.com.au> ---
(In reply to Olivier Hubert from comment #16)
> Note that I was unable to recreate the potential issue with only one worker
> seeing the changes once Module::Refresh does its job.
I just reproduced the problem on my first try with a standard
koha-testing-docker setup with 2 starman workers:
[2023/06/19 06:17:49] [WARN] It's a good thing you double-checked this plugin
before installing it. 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 48.
[2023/06/19 06:17:49] [WARN] You did check this plugin before installing it,
right? 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 50.
[2023/06/19 06:17:53] [WARN] It's a good thing you double-checked this plugin
before installing it. 0.0.3 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 48.
[2023/06/19 06:17:53] [WARN] You did check this plugin before installing it,
right? 0.0.3 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 50.
[2023/06/19 06:18:11] [WARN] It's a good thing you double-checked this plugin
before installing it. 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 48.
[2023/06/19 06:18:11] [WARN] You did check this plugin before installing it,
right? 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 50.
[2023/06/19 06:18:13] [WARN] It's a good thing you double-checked this plugin
before installing it. 0.0.3 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 48.
[2023/06/19 06:18:13] [WARN] You did check this plugin before installing it,
right? 0.0.3 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 50.
[2023/06/19 06:18:15] [WARN] It's a good thing you double-checked this plugin
before installing it. 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 48.
[2023/06/19 06:18:15] [WARN] You did check this plugin before installing it,
right? 0.0.4 28969 at
/var/lib/koha/kohadev/plugins/Koha/Plugin/Prosentient/NoisyPlugin.pm line 50.
The lines with 0.0.4 28969 are the one that was refreshed using the
Module::Refresh patch, and the lines with 0.0.3 are the 2nd Plack worker which
didn't get refreshed, since Module::Refresh didn't run in that process.
> Moving forward, if forcing a Plack refresh is not the way to go then I am
> unsure of the best approach. It seems to me like reading the plugin's main
> file on every use defeats the purpose of using Plack. Which is why I focused
> on doing it only when installing / upgrading.
There are ways...
1.
In the "plugin_data" table, we have __INSTALLED_VERSION__.
During get_enabled_plugins() and GetPlugins() and Koha::Plugins::Handler->run,
and probably other places..., we can compare $class->{metadata}->{version}
against __INSTALLED_VERSION__ (note this is a class lookup and not an object
lookup, so it would be called before calling the new() constructor to create an
object). You could fetch all values for the key __INSTALLED_VERSION__ in 1
database call to reduce overhead.
(As for reading the plugin's main file on every use - the file is already
loaded into the process's memory. So the plugin's coded information is already
available.)
2.
A Debian package friendly solution could be running
"kill('HUP',$starman_master_pid);" after installing/upgrading a plugin.
I talk about this at
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30897#c1
It's a bit of a nuclear option but it would be the cleanest.
3.
We could do a Plack middleware, although that would run for every single web
request. That's probably not necessary.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list