archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.67k stars 432 forks source link

Always revert queue worker to the central context — fix #1229 #1251

Closed stancl closed 2 months ago

stancl commented 2 months ago

This PR changes the QueueTenancyBootstrapper to always revert back to the previous context. In practice, this means reverting back to the central context unless dispatchNow() was used.

This addresses the issue described in #1229 where if the queue worker stayed in the tenant context, it would not respond to queue:restart signals.

The $forceRefresh static property is now unused and deprecated.

v4 will simplify the bootstrapper further since there are fewer backwards compatibility concerns.

stancl commented 2 months ago

@pr4xx Sorry about the delay on this, could you test the queue bootstrapper version from this PR?

https://raw.githubusercontent.com/archtechx/tenancy/e6ab0ee9af48771def77febc37933910cae52529/src/Bootstrappers/QueueTenancyBootstrapper.php

niconico291 commented 2 months ago

@stancl Thanks for the update. I deployed your version of the QueueTenancyBootstrapper to the testing environment and after a few short tests, it seems to work fine. I will report back after some more days of testing.

pr4xx commented 2 months ago

@stancl Some time has passed and had no issue with the updated code in production.

stancl commented 2 months ago

Awesome, thanks for all the help with this.