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
DB::afterCommit callbacks are executed before transaction level get decremented. So in case if callback do some actions inside it's own transaction and throws exception we will get Syntax error or access violation: 1305 SAVEPOINT trans2 does not exist DB error (percona in my case)
Steps To Reproduce:
<?phpdeclare(strict_types=1);
useIlluminate\Contracts\Console\Kernel;
$app = require_once__DIR__ . '/vendor/autoload.php';
$app = require_once__DIR__ . '/bootstrap/app.php';
/** @var \App\Console\Kernel $kernel */$kernel = $app->make(Kernel::class);
$kernel->bootstrap();
class SomeService
{
publicfunctionmainBusinessLogic()
{
\DB::transaction(function () {
// DO some business logic stuff here
\DB::afterCommit(function () {
$this->callSomeSecondaryBusinessLogic();
});
});
}
privatefunctioncallSomeSecondaryBusinessLogic()
{
\DB::transaction(function () {
// for instance this code should save some model// and dispatch job to db queue// so we need transaction here for surethrownew \RuntimeException('tst');
});
}
}
(newSomeService())->mainBusinessLogic();
The text was updated successfully, but these errors were encountered:
<?php
declare(strict_types=1);
use Illuminate\Contracts\Console\Kernel;
$app = require_once __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
/** @var \App\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
$kernel->bootstrap();
class SomeService
{
public function mainBusinessLogic()
{
\DB::transaction(function () {
// DO some business logic stuff here
\DB::afterCommit(function () {
echo 'after commit' . PHP_EOL;
$this->callSomeSecondaryBusinessLogic();
});
});
}
private function callSomeSecondaryBusinessLogic()
{
\DB::transaction(function () {
// for instance this code should save some model
// and dispatch job to db queue
// so we need transaction here for sure
});
}
}
(new SomeService())->mainBusinessLogic();
Description:
DB::afterCommit
callbacks are executed before transaction level get decremented. So in case if callback do some actions inside it's own transaction and throws exception we will getSyntax error or access violation: 1305 SAVEPOINT trans2 does not exist
DB error (percona in my case)Steps To Reproduce:
The text was updated successfully, but these errors were encountered: