Warning message during global destruction
jberger opened this issue · comments
I see that there is already a PR for a probably similar issue (#22) but I am getting a different error message:
(in cleanup) Can't call method "ping" on an undefined value at .../Mojo/mysql.pm line 82, line 307 during global destruction.
Manually I can suppress the warnings by changing line 82 from
while (my $c = shift @{$self->{queue} || []}) { return $c if $c->[0]->ping }
to
while (my $c = shift @{$self->{queue} || []}) { return $c if $c->[0] && $c->[0]->ping }
I don't get how you get into that situation: How come there's something doing _dequeue()
on global destruction? From what I can see, only db() calls _dequeue(), which means that at some point your code is calling $mysql->db
on global destruction..?
I'm not terribly sure either. I'm taking over a codebase where it seems to happen quite regularly. I THINK it might be related to Minion::Backend::mysql.
I'm closing this because of inactivity. Please re-open if you have new information.
Hi @jhthorsen
Got in the same situation. Below is some debug from my log file:
[Wed Nov 16 08:42:39 2016] [debug] Performing job "3" with task "test_task" in process 5803
[Wed Nov 16 08:42:39 2016] [warn] ================================================
[Wed Nov 16 08:42:39 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:39 2016] [warn] ================================================
[Wed Nov 16 08:42:39 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [debug] Reading configuration file "/apps/my_app/config/development.conf"
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
undef,
undef
];
[Wed Nov 16 08:42:41 2016] [warn] (in cleanup) Can't call method "ping" on an undefined value at /apps/my_app/local/lib/perl5/Mojo/mysql.pm line 82, <DATA> line 307 during global destruction.
[Wed Nov 16 08:42:41 2016] [debug] Helper "user" already exists, replacing
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [debug] Performing job "4" with task "test_task" in process 5806
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:41 2016] [warn] ================================================
[Wed Nov 16 08:42:41 2016] [warn] $VAR1 = [
bless( {}, 'DBI::db' ),
undef
];
[Wed Nov 16 08:42:42 2016] [warn] ================================================
[Wed Nov 16 08:42:42 2016] [warn] $VAR1 = [
undef,
undef
];
[Wed Nov 16 08:42:42 2016] [warn] (in cleanup) Can't call method "ping" on an undefined value at /apps/my_app/local/lib/perl5/Mojo/mysql.pm line 82, <DATA> line 307 during global destruction.
Those debug messages were produced by changing:
sub _dequeue {
my $self = shift;
my $dbh;
while (my $c = shift @{$self->{queue} || []}) { return $c if $c->[0]->ping }
to
sub _dequeue {
my $self = shift;
my $dbh;
use Data::Dumper;
while (my $c = shift @{$self->{queue} || []}) {
warn "================================================\n";
warn Dumper($c);
return $c if $c->[0]->ping
}
Basically I'm having a minion worker
running (script/my_app minion worker
) and I have generate a list of 50 jobs.
My test job looks like this:
$app->minion->add_task(test_task => sub {
my ($job, $args) = @_;
sleep(5);
$job->finish('Action complete.');
});
And this is how I've loaded up minion
:
my $config = $self->config->{ database };
my $dsn = sprintf('%s://%s:%s@%s/%s', $config->{ driver }, $config->{ user }, $config->{ password }, $config->{ host }, $config->{ database });
$self->plugin(Minion => {
$config->{ driver } => $dsn
});
Looks like changing this line
while (my $c = shift @{$self->{queue} || []}) { return $c if $c->[0]->ping }
to
while (my $c = shift @{$self->{queue} || []}) { return $c if $c->[0] && $c->[0]->ping }
fixes the issue.
Could you do this change please? Or should I create a pull request?
Cheers,
Adrian.
Sorry. My answer is still the same: I don't want to add patchwork without knowing what is causing this. Maybe Carp::Always
can give more information? Like where is this coming from?
What I like about your comment @crlcu, is that you have a minimal test case, which should make it easier to pin down the issue. I will re-open later when you have provided more information.
I am getting this relatively frequently in my tests.
I don't get how you get into that situation: How come there's something doing
_dequeue()
on global destruction? From what I can see, only db() calls _dequeue(), which means that at some point your code is calling$mysql->db
on global destruction..?
Yep your PubSub does it