Skip to content

Commit

Permalink
dont rollback to savepoints on deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
halaei committed Oct 15, 2016
1 parent 4de2ece commit 5e34cd1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ public function transaction(Closure $callback, $attempts = 1)
// up in the database. Then we'll re-throw the exception so it can
// be handled how the developer sees fit for their applications.
catch (Exception $e) {
// On deadlock, if this is a nested transaction, we cannot retry.
// the outer most transaction is rolled back by the server
// so we shouldn't rollback to save points.
if ($this->causedByDeadlock($e) && $this->transactions > 1) {
--$this->transactions;
throw $e;
}

$this->rollBack();

if ($this->causedByDeadlock($e) && $a < $attempts) {
Expand Down

0 comments on commit 5e34cd1

Please sign in to comment.