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

backstage: properly close DB connections in minion jobs #541

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ setup_system_user:
setup_system_db:
sudo -u postgres createuser mirrorcache
sudo -u postgres createdb mirrorcache
sudo -u postgres psql -c 'GRANT all ON SCHEMA public TO mirrorcache' mirrorcache

setup_production_assets:
cd "${DESTDIR}"/usr/share/mirrorcache/ && \
Expand Down
17 changes: 17 additions & 0 deletions lib/MirrorCache/WebAPI/Command/backstage/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ sub run {
$self->app->log->info('Resetting all leftover locks after restart');
$minion->reset({locks => 1});
}
$minion->on(
worker => sub () {
my (undef, $worker) = @_;
$worker->on(
dequeue => sub () {
my (undef, $job) = @_;
$job->on(
cleanup => sub () {
my ($j) = @_;
$j->app->minion->backend->mysql->close_idle_connections() unless $j->app->schema->pg;
$j->app->schema->disconnect_db;
}
);
}
);
}
);
$self->SUPER::run(@args);
}

Expand Down