You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How terrible is this (uses Try::Tiny::Retry)? The only obvious issue I see is that your code already reattempts connections for some of those exceptions so the total number of tries will be more.
sub retry_txn {
my ($self, $code, $rethrow) = @_;
my $dbc = $self->get_dbc();
return retry {
$dbc->txn(fixup => $code);
} delay {
return if $_[0] >= 10;
sleep 0.5*$_[0];
} on_retry {
warn "Retrying transaction.";
} retry_if {
my $err = $_;
$err = $err->error
if (eval { $err->isa('DBIx::Connector::RollbackError') });
$err =~ /deadlock|lost connection|gone away|can't connect/i;
} catch {
if ($rethrow) {
my $err = $_;
$err = $err->error
if (eval { $err->isa('DBIx::Connector::RollbackError') });
die $err;
}
};
}
Should work for serialization failures, too. See this blog post for details and discussion (especially the comments from Kevin Grittner).
The text was updated successfully, but these errors were encountered: