Closed DaveWishesHe closed 5 years ago
Are you using sync driver for jobs?
On my local environment, yes. I haven't put the code up anywhere to test on an alternate driver
I've had an experiment, and replacing TransactionalDispatcher.php line 35 like this seems to resolve the issue, but I'm unsure as to knock on impact of overriding Laravel's singleton pattern.
- $this->db = $container->make('db');
+ $this->db = clone $container->make('db');
I think the issue is because you are using sync queue. It won't happened on real workers cause every worker run single instance of db. But this case should be handled also. Please try redis as queue provider. Cloning db object is not a good idea at all
Yeah, works fine on the redis queue driver, will just crack on with the "it'll work up on the other environments" for now, thanks :)
Fixed in 0.4.0
Laravel 5.7
If the job being dispatched also contains a transaction, this gets stuck in a loop and eventually errors with
Maximum function nesting level of '512' reached, aborting!
Example:
MyService.php
DummyJobWithTransaction.php
In tinker:
Output in logs:
Presumably the issue is related to the fact that Laravel's DB is a singleton, so as soon as a fresh transaction opens, the TransactionalDispatcher starts waiting for the commit.