0

I made a Laravel app that uses the queue system (via database) to send emails. These emails are Job instances and are pushed to the queue after a cron-job is complete every 3 minutes or so.

If I run the artisan command

/path_to_php/7.1/bin/php artisan queue:work --queue=emails_1--tries=2 --daemon

in the terminal via SSH, it starts processing the jobs and sending emails. Obviously I would like to run this command and exit the terminal with it still running so I used the "nohup" approach.

nohup /path_to_php/7.1/bin/php artisan queue:work --queue=emails_1--tries=2 --daemon > storage/logs/laravel.log &

After running this I get a PDOException:

PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction in ...

I'm not really familiar with this error as I've never encountered something like this before but why can't I run the queue work command using nohup but can run it without problems without nohup? Any ideas as to why this is happening ? I'm using Laravel 5.2.

Please enlighten me. Thanks a lot.

mike.void
  • 172
  • 1
  • 2
  • 11
  • Duplicated by https://stackoverflow.com/questions/5836623/getting-lock-wait-timeout-exceeded-try-restarting-transaction-even-though-im – BDS Jun 05 '17 at 19:29

1 Answers1

0

Don't use the database queue driver in production. Try to avoid using the database queue driver when you're having a large queue, it's recommended that you use something like Redis which doesn't have the deadlock problems a database-based driver has.

Do you have additional info at Laravel Github: https://github.com/laravel/framework/issues/19242#issuecomment-302505260

Lito
  • 1,262
  • 2
  • 17
  • 25