Merge branch 'deadlocks-base-de-datos-en-cluster-de-percona-4137' into 'develop'
Retry queries when a deadlock is found. See merge request !936
This commit is contained in:
commit
7121d4a343
|
@ -805,25 +805,20 @@ sub db_delete_limit ($$$$;@) {
|
||||||
sub db_insert ($$$;@) {
|
sub db_insert ($$$;@) {
|
||||||
my ($dbh, $index, $query, @values) = @_;
|
my ($dbh, $index, $query, @values) = @_;
|
||||||
my $insert_id = undef;
|
my $insert_id = undef;
|
||||||
|
|
||||||
|
eval {
|
||||||
# MySQL
|
|
||||||
if ($RDBMS eq 'mysql') {
|
|
||||||
$dbh->do($query, undef, @values);
|
$dbh->do($query, undef, @values);
|
||||||
$insert_id = $dbh->{'mysql_insertid'};
|
$insert_id = $dbh->{'mysql_insertid'};
|
||||||
}
|
};
|
||||||
# PostgreSQL
|
if ($@) {
|
||||||
elsif ($RDBMS eq 'postgresql') {
|
my $exception = @_;
|
||||||
$insert_id = get_db_value ($dbh, $query . ' RETURNING ' . $RDBMS_QUOTE . $index . $RDBMS_QUOTE, @values);
|
if ($DBI::err == 1213) {
|
||||||
}
|
$dbh->do($query, undef, @values);
|
||||||
# Oracle
|
$insert_id = $dbh->{'mysql_insertid'};
|
||||||
elsif ($RDBMS eq 'oracle') {
|
}
|
||||||
my $sth = $dbh->prepare($query . ' RETURNING ' . $RDBMS_QUOTE . (uc ($index)) . $RDBMS_QUOTE . ' INTO ?');
|
else {
|
||||||
for (my $i = 0; $i <= $#values; $i++) {
|
die($exception);
|
||||||
$sth->bind_param ($i+1, $values[$i]);
|
|
||||||
}
|
}
|
||||||
$sth->bind_param_inout($#values + 2, \$insert_id, 99);
|
|
||||||
$sth->execute ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
|
@ -834,8 +829,20 @@ sub db_insert ($$$;@) {
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub db_update ($$;@) {
|
sub db_update ($$;@) {
|
||||||
my ($dbh, $query, @values) = @_;
|
my ($dbh, $query, @values) = @_;
|
||||||
|
my $rows;
|
||||||
my $rows = $dbh->do($query, undef, @values);
|
|
||||||
|
eval {
|
||||||
|
$rows = $dbh->do($query, undef, @values);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
my $exception = @_;
|
||||||
|
if ($DBI::err == 1213) {
|
||||||
|
$rows = $dbh->do($query, undef, @values);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
@ -1016,7 +1023,18 @@ sub db_do ($$;@) {
|
||||||
my ($dbh, $query, @values) = @_;
|
my ($dbh, $query, @values) = @_;
|
||||||
|
|
||||||
#DBI->trace( 3, '/tmp/dbitrace.log' );
|
#DBI->trace( 3, '/tmp/dbitrace.log' );
|
||||||
$dbh->do($query, undef, @values);
|
eval {
|
||||||
|
$dbh->do($query, undef, @values);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
my $exception = @_;
|
||||||
|
if ($DBI::err == 1213) {
|
||||||
|
$dbh->do($query, undef, @values);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
Loading…
Reference in New Issue