Skip to content

Instantly share code, notes, and snippets.

@SmellyFish
Last active July 6, 2016 17:27
Show Gist options
  • Save SmellyFish/b7ebef7f1b9cb318bd83121d2781a3be to your computer and use it in GitHub Desktop.
Save SmellyFish/b7ebef7f1b9cb318bd83121d2781a3be to your computer and use it in GitHub Desktop.
Transaction
try {
$connection->beginTransaction();
$connection->exec($insertQuery, $insertValues);
if ($lastProspectId) {
$listEmail->setClientType($lastProspectId);
$listEmail->save($connection);
}
$connection->commit();
$queuedSuccessfully = true;
} catch (Exception $e) {
$connection->rollback();
if (EmailManager::exceptionIndicatesDeadlock($e)) {
//retry on deadlock
$queueException = $e;
} else {
//non-deadlock, bail out immediately w/o retrying
GraphiteClient::increment('email.failure.queue.nodeadlock');
...
throw $e;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment