bash has asked for the wisdom of the Perl Monks concerning the following question:
Is it correct way?eval { $dbh->do(...); }; if (my $e = $@) { if ($dbh->{Active} != 1 || $dbh->state =~ /08\d{3}/){ # reconnect and retry } else { # not connection related error } }
My observation shows that:unless (fork()) { $dbh->{InactiveDestroy} = 0; exit; } wait();
sub query { $dbh->selectrow_array(q{ SELECT now() }); } sub ping_and_query { $dbh->selectrow_array(q{ SELECT now() }) if $dbh->ping; } cmpthese(-2, { 'query' => \&query, 'ping+query' => \&ping_and_query, }); --- Rate ping+query query ping+query 6349/s -- -39% query 10327/s 63% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Handle DBI connection lost
by RonW (Parson) on Feb 22, 2017 at 23:24 UTC | |
|
Re: Handle DBI connection lost
by Mr. Muskrat (Canon) on Feb 23, 2017 at 16:04 UTC | |
by bash (Scribe) on Feb 27, 2017 at 12:45 UTC | |
|
Re: Handle DBI connection lost
by Your Mother (Archbishop) on Feb 24, 2017 at 15:46 UTC | |
by bash (Scribe) on Feb 27, 2017 at 12:59 UTC | |
|
Re: Handle DBI connection lost
by Anonymous Monk on Feb 22, 2017 at 19:38 UTC | |
by bash (Scribe) on Feb 22, 2017 at 21:40 UTC | |
by Laurent_R (Canon) on Feb 22, 2017 at 22:22 UTC | |
by bash (Scribe) on Feb 23, 2017 at 01:40 UTC | |
|
Re: Handle DBI connection lost
by gsiems (Deacon) on Feb 24, 2017 at 19:14 UTC | |
by bash (Scribe) on Feb 27, 2017 at 12:47 UTC | |
by Anonymous Monk on Feb 28, 2017 at 00:12 UTC | |
by bash (Scribe) on Feb 28, 2017 at 06:14 UTC |