clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

Multitenant duplicate query issue with Artisan::call

Open mattvb91 opened this issue 10 months ago • 2 comments

I have the following pseudo code:

foreach($tenants as $tenant) {
        Artisan::call('command', ['--uid' => $tenant->id]);
}

This seems to be calling clock->storeRequest() after each Artisan::call(), However what seems to be happening is that each $request->databaseQueries is not reset and is appended to with the previous databaseQueries added on top leading to duplicate queries being shown in clockwork that weren't actually executed.

Any guidance on how to handle situations like this where im tracking individual commands within the context of a global request?

i realize this is a difficult example for a reproducible, if we are completely stuck I will try to create a sample repo

mattvb91 avatar Feb 18 '25 13:02 mattvb91

Hey, thanks for the report, I will try to investigate this weekend.

itsgoingd avatar Mar 14 '25 14:03 itsgoingd

This should be now fixed in master (https://github.com/itsgoingd/clockwork/commit/229a43f1b663ea0cf418e4f9ca58448315765484). Database queries from the called commands should now be correctly included in the parent command as intended.

itsgoingd avatar Apr 20 '25 11:04 itsgoingd

Fixed in Clockwork 5.3.5.

itsgoingd avatar Sep 14 '25 15:09 itsgoingd