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();