Skip to content

Database Transaction Error on Laravel Queue Runner #42503

Closed
@sayemk

Description

@sayemk
  • Laravel Version: 6.20.43
  • PHP Version: 7.3.18
  • Database Driver & Version: Aurora MySQL 5.7

Description:

prod.ERROR: There is already an active transaction {"exception":"[object] (PDOException(code: 0): There is already an active transaction at /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:133)
[stacktrace]
#0 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(133): PDO->beginTransaction()
#1 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(115): Illuminate\Database\Connection->createTransaction()
#2 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(23): Illuminate\Database\Connection->beginTransaction()
#3 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(203): Illuminate\Database\Connection->transaction(Object(Closure))
#4 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(284): Illuminate\Queue\DatabaseQueue->pop('default')
#5 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(123): Illuminate\Queue\Worker->getNextJob(Object(Illuminate\Queue\DatabaseQueue), 'default')
#6 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#7 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#8 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#9 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#10 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#11 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#12 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#13 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\Container\Container->call(Array)
#14 /usr/share/nginx/html/nautilus-report/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#15 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#16 /usr/share/nginx/html/nautilus-report/vendor/symfony/console/Application.php(1009): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /usr/share/nginx/html/nautilus-report/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /usr/share/nginx/html/nautilus-report/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /usr/share/nginx/html/nautilus-report/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Steps To Reproduce:

Run the Queue as a Daemon and in the meantime if the DB driver gets an error or restart or connection is lost before committing then this error occurs.

FYI

I am running the queue in supervisor with one process and the command is artisan queue:work database --sleep=5 --tries=2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions