From 7b5903f3ee1ba5125c60a8c00b5415d9734aeb68 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Wed, 29 Nov 2023 09:38:36 +0100 Subject: [PATCH] Improve handling and configuration of GenerateFederatedSearchIndex job If the default queue was congested, the job would not be run within 1 hour. When the "fetch index" request came from another instance, it would attempt to generate the index synchronously because the index was not there in the cache. This failed because generating the index took longer than the 30 s request timeout. Now the job is dispatched 30 min before the requests should arrive. Also, the job can be pushed to a higher priority queue. --- app/Console/Kernel.php | 5 +++-- config/biigle.php | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 19b62a5aa..bedce30d4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -30,13 +30,14 @@ protected function schedule(Schedule $schedule): void $schedule ->call(function () { if (FederatedSearchInstance::withLocalToken()->exists()) { - GenerateFederatedSearchIndex::dispatch(); + GenerateFederatedSearchIndex::dispatch() + ->onQueue(config('biigle.federated_search.index_queue')); } }) ->name('generate-federated-search-index') // The requests to retrieve the federated search index are sent hourly at 05. // This should not collide with this job to generate the index. - ->hourlyAt(55) + ->hourlyAt(35) ->onOneServer(); $schedule diff --git a/config/biigle.php b/config/biigle.php index bb1f0ee9d..835c85ea2 100644 --- a/config/biigle.php +++ b/config/biigle.php @@ -44,6 +44,11 @@ | Cache key to use for the federated search index. */ 'cache_key' => env('BIIGLE_FEDERATED_SEARCH_CACHE_KEY', 'federated_search_index'), + + /* + | The queue to submit the "generate federated search index" job to. + */ + 'index_queue' => env('BIIGLE_FEDERATED_SEARCH_INDEX_QUEUE', 'default'), ], ];