https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43937 Bug ID: 43937 Summary: Koha::Plugins::Loader does not cache the empty list of enabled plugins Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Plugin architecture Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org CC: kyle@bywatersolutions.com, martin.renvoize@openfifth.co.uk, tomascohen@gmail.com Target Milestone: --- Koha::Plugins::Loader->get_enabled_plugins caches the list of enabled plugins in Koha::Cache::Memory::Lite, but only when it is not empty: Koha::Cache::Memory::Lite->set_in_cache( $cache_key, \@plugins ) if @plugins; So when plugins are enabled in koha-conf.xml (enable_plugins) but no plugin is enabled, every call to Koha::Plugins->call, Koha::Plugins->get_enabled_plugins or Koha::Plugins->feature_enabled checks that the plugin_data table exists and queries it again. Some plugin hooks are called for each item: for instance, Koha::Item->store calls two of them. The code before bug 38384 cached the empty list too. In KTD (no plugin enabled), storing the 3000 items of a record in a loop runs 6000 queries on plugin_data and 6000 table_exists checks, and takes 77 s. With the empty list cached: 1 query, 1 check, 47 s. This was discussed in bug 38384 comment 55, and the test was adjusted to the behaviour. The reason the empty list was not cached (comment 36) was that the early loading could not find the plugins yet; that loading has since moved to the BEGIN block of Koha::Plugins, after pluginsdir is added to @INC. However, caching the empty list has a side effect on the workers. Koha::Cache::Memory::Lite is flushed for each request under Plack, but background_jobs_worker.pl and es_indexer_daemon.pl never flush it, and they load Koha::Plugins (and so the enabled plugins) when they start: each job runs in a child process that inherits the cached list. This already means that, when at least one plugin is enabled, the workers do not see the plugins enabled or disabled afterwards until they are restarted. With no plugin enabled they currently see the first enabled plugin, only because the empty list is not cached. Proposed fix: - cache the empty list in Koha::Plugins::Loader - flush Koha::Cache::Memory::Lite in the workers before each job, as Plack does for each request, so that plugin changes are picked up without restarting them (es_indexer_daemon.pl already flushes the L1 cache before each job, for the system preferences) -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.