Manage inactive handles in forks in Mojo::Pg

32 views
Skip to first unread message

Andrey Khozov

unread,
Aug 17, 2016, 2:42:22 AM8/17/16
to Mojolicious
I see, that Mojo::Pg use AutoInactiveDestroy DBI options for dbh, but I have some issues with inactive handles in childs.

Minimal example:

use Mojolicious::Lite; use Minion; use Mojo::Pg; use Test::More; use Test::Mojo; my $pg_uri = 'postgresql://and@/test'; app->plugin(Minion => {Pg => $pg_uri}); app->helper(pg => sub { state $pg = Mojo::Pg->new($pg_uri) }); app->minion->add_task(test => sub {}); my $worker = app->minion->worker->register; app->minion->on(enqueue => sub { $worker->dequeue(1)->start }); get '/' => sub { my $c = shift; my $db = $c->pg->db; my $tx = $db->begin; $db->query('select 1'); $c->minion->enqueue('test'); $tx->commit; $c->render(text => 'ok'); }; app->start; my $t = Test::Mojo->new; $t->get_ok('/')->status_is(200); done_testing;

​And result with strange warning:

app.pl .. [Wed Aug 17 11:30:32 2016] [debug] GET "/"
[Wed Aug 17 11:30:32 2016] [debug] Routing to a callback
[Wed Aug 17 11:30:32 2016] [debug] 200 OK (0.013601s, 73.524/s)
WARNING:  there is no transaction in progress

ok 1 - GET /
ok 2 - 200 OK
1..2
ok
All tests successful.
Should Mojo::Pg close all dbh while fork? How I can avoid similar warnings?

--
Andrey Khozov
Reply all
Reply to author
Forward
0 new messages