DBI::db disconnect() and finish()

  • Thread starter francois.x.hetu
  • Start date
F

francois.x.hetu

Hi,

I have this subroutine, called periodically by cron, which always gives

out this error:


Cron <otrs at xxx> $HOME/bin/GenericAgent.pl -c db >> /dev/null


DBI::db=HASH(0xa778fd8)->disconnect invalidates 1 active statement
handle
(either destroy statement handles or call finish on them before
disconnecting) at /opt/otrs/Kernel/System/DB.pm line 219, <PRODUCT>
line 4.


Here is the subroutine:


sub Disconnect {
my $Self = shift;
# debug
if ($Self->{Debug} > 2) {
$Self->{LogObject}->Log(
Caller => 1,
Priority => 'debug',
Message => "DB.pm->Disconnect",
);
}
#$Self->{dbh}->finish() if ($Self->{dbh});
# do disconnect
$Self->{dbh}->disconnect() if ($Self->{dbh});
return 1;



}


I tried to put the line, as above (not commented out off course):

$Self->{dbh}->finish() if ($Self->{dbh});


This in turn gave me this error:


Cron $HOME/bin/GenericAgent.pl -c db >> /dev/null


(in cleanup) Can't locate object method "finish" via package "DBI::db"
at
/opt/otrs/Kernel/System/DB.pm line 220, <PRODUCT> line 4.


Or:


Cron $HOME/bin/PostMasterPOP3.pl >> /dev/null


(in cleanup) Can't call method "finish" on an undefined value at
/opt/otrs/Kernel/System/DB.pm line 220, <PRODUCT> line 4 during global
destruction.


Being new to the Perl universe, I'm a little baffled by those errors.
I'm looking for a practical way to remove all error messages linked to
the use of disconnect(), especially since those errors do not, it
seems, help me target a real problem: from what I gather, all db
operations run fine.


Thanks


François
 
X

xhoster

Hi,

I have this subroutine, called periodically by cron, which always gives

out this error:

Cron <otrs at xxx> $HOME/bin/GenericAgent.pl -c db >> /dev/null

DBI::db=3DHASH(0xa778fd8)->disconnect invalidates 1 active statement
handle
(either destroy statement handles or call finish on them before
disconnecting) at /opt/otrs/Kernel/System/DB.pm line 219, <PRODUCT>
line 4.

OK, so you have an active statement handle being held someplace. Where
are you holding it?
Here is the subroutine:

sub Disconnect {
my $Self =3D shift;
# debug
if ($Self->{Debug} > 2) {
$Self->{LogObject}->Log(
Caller =3D> 1,
Priority =3D> 'debug',
Message =3D> "DB.pm->Disconnect",
);
}
#$Self->{dbh}->finish() if ($Self->{dbh});
# do disconnect
$Self->{dbh}->disconnect() if ($Self->{dbh});
return 1;

}

I tried to put the line, as above (not commented out off course):

$Self->{dbh}->finish() if ($Self->{dbh});

This in turn gave me this error:

Cron $HOME/bin/GenericAgent.pl -c db >> /dev/null

(in cleanup) Can't locate object method "finish" via package "DBI::db"
at
/opt/otrs/Kernel/System/DB.pm line 220, <PRODUCT> line 4.

You need to "finish" the statement handle, not the database handle.
For example, is you store the statement handle in sth, then
$Self->{sth}->finish();

Being new to the Perl universe, I'm a little baffled by those errors.
I'm looking for a practical way to remove all error messages linked to
the use of disconnect(), especially since those errors do not, it
seems, help me target a real problem: from what I gather, all db
operations run fine.

If you wish to ignore the warnings of calling disconnect, then don't
explicitly call disconnect. When the dbh goes out of scope, or the program
ends, the handle will automatically go be disconnected, and will do so
without this particular warning message.

Xho
 
F

François

(e-mail address removed) a écrit :
OK, so you have an active statement handle being held someplace. Where
are you holding it?
You need to "finish" the statement handle, not the database handle.
For example, is you store the statement handle in sth, then
$Self->{sth}->finish();
If you wish to ignore the warnings of calling disconnect, then don't
explicitly call disconnect. When the dbh goes out of scope, or the program
ends, the handle will automatically go be disconnected, and will do so
without this particular warning message.

Xho


Thanks Xho for your answer.

Since the statement handle is all over the place (called from many
different libraries of which I haven't written a single line), it's
rather difficult to refactor the code. I could just comment out the
disconnect statement. Just want to be sure it will not impair further
connections, since this program is running every 10 minutes or so,
triggered by cron. I will try, and get back with the result.

François
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top