Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Elastic Search is down, No alive nodes error is still thrown even if using Laravel queues #93

Closed
chrisgrim opened this issue Oct 20, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@chrisgrim
Copy link

Software Version
PHP 8.0.3
Elasticsearch 7.12.0
Laravel 8.36.2
Laravel Scout ^8.6
Elastic Scout Driver ^1.3

When I would save a model that was searchable and elastic search was down it would throw an error and cause issues for the user. I was recommended to use laravel queues to fix this issue. I set it up and have been using it for my project and everything works great using the queues. However as soon as I turn off elastic search to test it out I get the error below. I looked at the jobs database and I see that it hasn't even had a chance to save the job, its is erroring out before hand. If I turn elastic search back on I can see the jobs are submitted to the jobs database.
Does this mean that something else is erroring out before scout can send the job to the queue.

[2021-10-20 05:49:19] production.ERROR: No alive nodes found in your cluster {"userId":1,"exception":"[object] (Elasticsearch\\Common\\Exceptions\\NoNodesAvailableException(code: 0): No alive nodes found in your cluster at /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php:64)
[stacktrace]
#0 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(82): Elasticsearch\\ConnectionPool\\StaticNoPingConnectionPool->nextConnection()
#1 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(99): Elasticsearch\\Transport->getConnection()
#2 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(297): Elasticsearch\\Transport->performRequest()
#3 /var/www/html/ei/vendor/react/promise/src/FulfilledPromise.php(28): Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}()
#4 /var/www/html/ei/vendor/ezimuel/ringphp/src/Future/CompletedFutureValue.php(55): React\\Promise\\FulfilledPromise->then()
#5 /var/www/html/ei/vendor/ezimuel/ringphp/src/Core.php(341): GuzzleHttp\\Ring\\Future\\CompletedFutureValue->then()
#6 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(345): GuzzleHttp\\Ring\\Core::proxy()
#7 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(241): Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}()
#8 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(110): Elasticsearch\\Connections\\Connection->performRequest()
#9 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(1671): Elasticsearch\\Transport->performRequest()
#10 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(331): Elasticsearch\\Client->performRequest()
#11 /var/www/html/ei/vendor/babenkoivan/elastic-adapter/src/Documents/DocumentManager.php(57): Elasticsearch\\Client->bulk()
#12 /var/www/html/ei/vendor/babenkoivan/elastic-scout-driver/src/Engine.php(82): ElasticAdapter\\Documents\\DocumentManager->delete()
#13 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): ElasticScoutDriver\\Engine->delete()
#14 /var/www/html/ei/vendor/babenkoivan/elastic-scout-driver-plus/src/Decorators/EngineDecorator.php(42): ElasticScoutDriverPlus\\Decorators\\EngineDecorator->forwardCallTo()
#15 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(83): ElasticScoutDriverPlus\\Decorators\\EngineDecorator->__call()
#16 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(46): App\\Models\\Event->queueRemoveFromSearch()
#17 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php(114): Illuminate\\Database\\Eloquent\\Collection->Laravel\\Scout\\{closure}()
#18 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(176): Illuminate\\Support\\Collection->__call()
#19 /var/www/html/ei/vendor/laravel/scout/src/ModelObserver.php(82): App\\Models\\Event->unsearchable()
#20 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(412): Laravel\\Scout\\ModelObserver->saved()
#21 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(237): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#22 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php(189): Illuminate\\Events\\Dispatcher->dispatch()
#23 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(899): Illuminate\\Database\\Eloquent\\Model->fireModelEvent()
#24 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(870): Illuminate\\Database\\Eloquent\\Model->finishSave()
#25 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(816): Illuminate\\Database\\Eloquent\\Model->save()
#26 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/helpers.php(263): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}()
#27 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(817): tap()
#28 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->create()
#29 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1890): Illuminate\\Database\\Eloquent\\Model->forwardCallTo()
#30 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1902): Illuminate\\Database\\Eloquent\\Model->__call()
#31 /var/www/html/ei/app/Models/Event.php(421): Illuminate\\Database\\Eloquent\\Model::__callStatic()
#32 /var/www/html/ei/app/Http/Controllers/EventController.php(81): App\\Models\\Event::newEvent()
#33 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\EventController->store()
#34 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#35 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Route.php(254): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#36 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Route.php(197): Illuminate\\Routing\\Route->runController()
#37 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Route->run()
#38 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#39 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\EnsureEmailIsVerified->handle()
#41 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#43 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle()
#45 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#47 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#49 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#51 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()
#52 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#54 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#56 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#57 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()
#58 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()
#59 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()
#60 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()
#61 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\\Routing\\Router->dispatch()
#62 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#63 /var/www/html/ei/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#64 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
#65 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#66 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#67 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#68 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#69 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#70 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#71 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#72 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#73 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#74 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#75 /var/www/html/ei/vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#76 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()
#77 /var/www/html/ei/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#78 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()
#79 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#80 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then()
#81 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#82 /var/www/html/ei/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#83 {main}
"} 

Here is an example job payload when elastic search is on to show that queues are working.
{"uuid":"9b4d91c7-ea0c-451b-9fb2-17f130b49d43","displayName":"Laravel\\Scout\\Jobs\\MakeSearchable","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"Laravel\\Scout\\Jobs\\MakeSearchable","command":"O:33:\"Laravel\\Scout\\Jobs\\MakeSearchable\":10:{s:6:\"models\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":4:{s:5:\"class\";s:16:\"App\\Models\\Event\";s:2:\"id\";a:1:{i:0;i:1113;}s:9:\"relations\";a:5:{i:0;s:9:\"favorites\";i:1;s:11:\"priceranges\";i:2;s:5:\"shows\";i:3;s:10:\"age_limits\";i:4;s:9:\"organizer\";}s:10:\"connection\";s:5:\"mysql\";}s:10:\"connection\";s:8:\"database\";s:5:\"queue\";N;s:15:\"chainConnection\";N;s:10:\"chainQueue\";N;s:19:\"chainCatchCallbacks\";N;s:5:\"delay\";N;s:11:\"afterCommit\";N;s:10:\"middleware\";a:0:{}s:7:\"chained\";a:0:{}}"}}

@chrisgrim chrisgrim added the bug Something isn't working label Oct 20, 2021
@babenkoivan
Copy link
Owner

Hey @chrisgrim, were you able to resolve the issue? From the call stack you shared, I can conclude that Laravel decided that queues are not configured:

#15 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(83): ElasticScoutDriverPlus\\Decorators\\EngineDecorator->__call()

Searchable.php(83) corresponds to the line inside the if condition:

if (! config('scout.queue')) {
    return $models->first()->searchableUsing()->delete($models);
}

Have you reset the config cache after enabling the queues?

@chrisgrim
Copy link
Author

I ran php artisan config:cache and cleared the cache.
Here is my .env file

QUEUE_CONNECTION=database
SCOUT_DRIVER=elastic
SCOUT_QUEUE=true

and just to be safe I updated my config.scout file

'driver' => env('SCOUT_DRIVER', 'elastic'),
'queue' => env('SCOUT_QUEUE', true),

I event tried editing the Searchable.php file itself on line 83 and still I am getting the same error

[2021-11-02 19:24:53] production.ERROR: No alive nodes found in your cluster {"userId":1,"exception":"[object] (Elasticsearch\\Common\\Exceptions\\NoNodesAvailableException(code: 0): No alive nodes found in your cluster at /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php:64)
[stacktrace]
#0 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(82): Elasticsearch\\ConnectionPool\\StaticNoPingConnectionPool->nextConnection()
#1 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(99): Elasticsearch\\Transport->getConnection()
#2 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(297): Elasticsearch\\Transport->performRequest()
#3 /var/www/html/ei/vendor/react/promise/src/FulfilledPromise.php(28): Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}()
#4 /var/www/html/ei/vendor/ezimuel/ringphp/src/Future/CompletedFutureValue.php(55): React\\Promise\\FulfilledPromise->then()
#5 /var/www/html/ei/vendor/ezimuel/ringphp/src/Core.php(341): GuzzleHttp\\Ring\\Future\\CompletedFutureValue->then()
#6 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(345): GuzzleHttp\\Ring\\Core::proxy()
#7 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(241): Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}()
#8 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(110): Elasticsearch\\Connections\\Connection->performRequest()
#9 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(1671): Elasticsearch\\Transport->performRequest()
#10 /var/www/html/ei/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(331): Elasticsearch\\Client->performRequest()
#11 /var/www/html/ei/vendor/babenkoivan/elastic-adapter/src/Documents/DocumentManager.php(57): Elasticsearch\\Client->bulk()
#12 /var/www/html/ei/vendor/babenkoivan/elastic-scout-driver/src/Engine.php(82): ElasticAdapter\\Documents\\DocumentManager->delete()
#13 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): ElasticScoutDriver\\Engine->delete()
#14 /var/www/html/ei/vendor/babenkoivan/elastic-scout-driver-plus/src/Decorators/EngineDecorator.php(42): ElasticScoutDriverPlus\\Decorators\\EngineDecorator->forwardCallTo()
#15 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(83): ElasticScoutDriverPlus\\Decorators\\EngineDecorator->__call()
#16 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(46): App\\Models\\Event->queueRemoveFromSearch()
#17 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php(114): Illuminate\\Database\\Eloquent\\Collection->Laravel\\Scout\\{closure}()
#18 /var/www/html/ei/vendor/laravel/scout/src/Searchable.php(176): Illuminate\\Support\\Collection->__call()
#19 /var/www/html/ei/vendor/laravel/scout/src/ModelObserver.php(82): App\\Models\\Event->unsearchable()
#20 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(412): Laravel\\Scout\\ModelObserver->saved()
#21 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(237): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#22 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php(189): Illuminate\\Events\\Dispatcher->dispatch()
#23 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(899): Illuminate\\Database\\Eloquent\\Model->fireModelEvent()
#24 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(870): Illuminate\\Database\\Eloquent\\Model->finishSave()
#25 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(816): Illuminate\\Database\\Eloquent\\Model->save()
#26 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/helpers.php(263): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}()
#27 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(817): tap()
#28 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->create()
#29 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1890): Illuminate\\Database\\Eloquent\\Model->forwardCallTo()
#30 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1902): Illuminate\\Database\\Eloquent\\Model->__call()
#31 /var/www/html/ei/app/Models/Event.php(421): Illuminate\\Database\\Eloquent\\Model::__callStatic()
#32 /var/www/html/ei/app/Http/Controllers/EventController.php(81): App\\Models\\Event::newEvent()
#33 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\EventController->store()
#34 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#35 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Route.php(254): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#36 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Route.php(197): Illuminate\\Routing\\Route->runController()
#37 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Route->run()
#38 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#39 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\EnsureEmailIsVerified->handle()
#41 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#43 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle()
#45 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#47 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#49 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#51 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()
#52 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#54 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#56 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#57 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()
#58 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()
#59 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()
#60 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()
#61 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\\Routing\\Router->dispatch()
#62 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#63 /var/www/html/ei/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#64 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
#65 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#66 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#67 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#68 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#69 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#70 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#71 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#72 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#73 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#74 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#75 /var/www/html/ei/vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#76 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()
#77 /var/www/html/ei/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#78 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()
#79 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#80 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then()
#81 /var/www/html/ei/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#82 /var/www/html/ei/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#83 {main}
"} 

Is there a better way to test this?
Thanks!!!

@babenkoivan
Copy link
Owner

Hi @chrisgrim, I tried locally, and it seems to be working for me. Can you try to check what config you have inside Searchable::queueRemoveFromSearch() and Searchable::queueMakeSearchable() methods (i.e. by calling config("scout"))? You can print it on the screen or log it in a file, and then share the results here.

@chrisgrim
Copy link
Author

Hi @babenkoivan
I just tried doing
return config("scout");
and it returns

{
"driver": "elastic",
"prefix": "",
"queue": true,
"after_commit": false,
"chunk": {
"searchable": 500,
"unsearchable": 500
},
"soft_delete": false,
"identify": false,
"algolia": {
"id": "",
"secret": ""
}
}

So I think I am doing something wrong. However, if I SSH into my server and open the searchable.php file in my vendor folder I get

    public function queueRemoveFromSearch($models)
    {
        if ($models->isEmpty()) {
            return;
        }

        return $models->first()->searchableUsing()->delete($models);
    }

public function queueMakeSearchable($models)
    {
        if ($models->isEmpty()) {
            return;
        }

        if (! config('scout.queue')) {
            return $models->first()->searchableUsing()->update($models);
       }


        dispatch((new MakeSearchable($models))
                ->onQueue($models->first()->syncWithSearchUsingQueue())
                ->onConnection($models->first()->syncWithSearchUsing()));
    }

@babenkoivan
Copy link
Owner

Hey @chrisgrim, thanks for the hint. Apparently, some of your models become unsearchable when saved due to:

if (! $model->shouldBeSearchable()) {
    if ($model->wasSearchableBeforeUpdate()) {
        $model->unsearchable();
    }

    return;
}

queueRemoveFromSearch supports queues starting from Scout 9.1.0:

public function queueRemoveFromSearch($models)
{
    if ($models->isEmpty()) {
        return;
    }

    if (! config('scout.queue')) {
        return $models->first()->searchableUsing()->delete($models);
    }

    dispatch(new Scout::$removeFromSearchJob($models))
        ->onQueue($models->first()->syncWithSearchUsingQueue())
        ->onConnection($models->first()->syncWithSearchUsing());
}

I suggest you update Scout at least to 9.1. Hope this helps!

@chrisgrim
Copy link
Author

@babenkoivan
That worked!!! Thank you sooo much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants