laravel-multitenancy: Queue retry fails for tenant aware jobs
Hello,
Forgive me if I’m wrong, but I think that there is an issue when trying to retry failed tenant aware jobs.
- configuration
queues_are_tenant_aware_by_default
set totrue
- Not trying to add the jobs into the tenant databases (most of issues are related to this)
- Typical failed job retry
php artisan queue:retry ID
fails because it can not unserialize the payload command at \Illuminate\Queue\Console\RetryCommand::refreshRetryUntil. Switch tenant database never called…
- Retry job via tenant aware command - NO tenant specified
php artisan tenants:artisan "queue:retry ID"
partially works but it’s executed for every tenant which means that command will succeed only once and will fail for all other tenants.
- Retry job via tenant aware command - tenant specified
php artisan tenants:artisan "queue:retry ID" --tenant=TENANT_ID
works as it should but this means that every time we should check for the TENANT_ID
at the payload which is nasty 😉. When you have a lot jobs failed it’s even worse…
Possible solution could be if we have tenant aware queue retry command that could extend \Illuminate\Queue\Console\RetryCommand
and wrap retryJob
parents method with set/forget tenant calls if it’s a tenant aware job of course.
What do you think about this solution? Any better ideas?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (7 by maintainers)
Commits related to this issue
- Handle `JobRetryRequested` queue event and fix #259 — committed to aginev/laravel-multitenancy by aginev 3 years ago
- Merge pull request #298 from aginev/master Handle `JobRetryRequested` queue event and fix #259 — committed to spatie/laravel-multitenancy by masterix21 3 years ago
Merged 🥳
@aginev, I can confirm the bug: I’m working to a fix. Thanks.
@aginev yes, submit the PR but please fix the line
with
Thanks for your work on it.
Nice, well done 👍