https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36736

--- Comment #2 from Nick Clemens (kidclamp) <[email protected]> ---
So, I played around here a bit - my first thought was that we could simply
avoid the reconnect if the objects were already loaded, so I updated a plugin
like so:

$schema = Koha::Database->schema({ new => 1 }) unless
$schema->source_registrations->{KohaPluginComBywatersolutionsContractsContract};

With some warns I found that this was executed when plack was restarted, so the
object are loaded in plack from the start, that's good. But I found that
imports still failed and caused reconnect - that's bad.

What I eventually realized was that we are forking our background jobs - and
these get a new DB connection, without the new objects. The dirty fix that
worked was adding to the worker:
Koha::Plugins->get_enabled_plugins;

After spawning the process, but before beginning the job. And that fixes it.

I am not sure where we load the plugins when we start plack, but if we did the
same thing when launching a background worker process - or built it in to the
process method of BackgroundJob

To move the logic out of the plugin we could add a 'plugin_classes' method and
have Koha::Schema check for if the objects are loaded - but I think maybe just
loading plugins for the background tasks at spawn is a good start?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to