cancel
Showing results for 
Search instead for 
Did you mean: 

Elasticsearch CRITICAL errors - products disappear from categories

Elasticsearch CRITICAL errors - products disappear from categories

Hi

 

Magento v 2.4.5

Elasticsearch v 7.17.9

 

This has been an ongoing intermittent issue for several months.

All products (15000+) suddenly do not show in categories on the frontend. Products can be seen through their direct URL.

This appears to happen when staff are editing products, or switching them between categories in the backend, although this is not reproduceable so it may be coincidental.

 

We have made the following changes over the past few weeks:

- Upgraded Elasticsearch from 6.8.23 to 7.17.9

- Corrected an issue where our POS system was using the same Elasticsearch indices for LIVE and STAGING sites.

 

Before these changes we used to get Elasticsearch crashing at the same time as the products all disappearing. To bring back all products we would run:

 

service elasticsearch restart
php bin/magento indexer:reindex

 

Since upgrading Elasticsearch it is no longer crashing.

To solve the problem now we just reindex.

 

System.log shows errors like this at or around the time the products disappear:

 

[2023-03-06T20:55:11.703339+00:00] main.CRITICAL: Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [position_category_9] in order to sort on","index_uuid":"gaRlC2HOSy2-X4XnI0kzQQ","index":"magento2_webpos_productsearch_fulltext_1_v84"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_webpos_productsearch_fulltext_1_v84","node":"Em9qFtSWSpafRrRYnfSzvg","reason":{"type":"query_shard_exception","reason":"No mapping found for [position_category_9] in order to sort on","index_uuid":"gaRlC2HOSy2-X4XnI0kzQQ","index":"magento2_webpos_productsearch_fulltext_1_v84"}}]},"status":400} in /home/*********/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:693

 

magento2_webpos_productsearch_fulltext_1_v84 is an index used by our POS system. I have queried this with them as well.

 

Any suggestions of what might be happening, or where to look next would be really useful!

Thanks

Ben

 

Some details about our Elasticsearch below:

 

curl http://localhost:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 51,
"active_shards" : 51,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 48,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 51.515151515151516
}

 

service elasticsearch status
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-03-06 20:26:37 GMT; 12h ago
Docs: https://www.elastic.co
Main PID: 26680 (java)
CGroup: /system.slice/elasticsearch.service
├─26680 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+Alwa...
└─26936 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Mar 06 20:26:25 ssd356r.simpleservers.co.uk systemd[1]: Starting Elasticsearch...
Mar 06 20:26:37 ssd356r.simpleservers.co.uk systemd[1]: Started Elasticsearch.

 

curl -XGET 'http://localhost:9200'
{
"name" : "***********",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "ZOn1c039RZCAGehzZ3D8tw",
"version" : {
"number" : "7.17.9",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "ef48222227ee6b9e70e502f0f0daa52435ee634d",
"build_date" : "2023-01-31T05:34:43.305517834Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

 

curl http://localhost:9200/_aliases?pretty=true
{
"magento2staging_product_3_v3" : {
"aliases" : {
"magento2staging_product_3" : { }
}
},
"magento2_product_1_v2" : {
"aliases" : {
"magento2_product_1" : { }
}
},
"magento2staging_product_5_v3" : {
"aliases" : {
"magento2staging_product_5" : { }
}
},
"magento2_product_5_v2" : {
"aliases" : {
"magento2_product_5" : { }
}
},
"magento2staging_webpos_productsearch_fulltext_1_v3" : {
"aliases" : {
"magento2staging_webpos_productsearch_fulltext_1" : { }
}
},
"magento2_webpos_productsearch_fulltext_3_v2" : {
"aliases" : {
"magento2_webpos_productsearch_fulltext_3" : { }
}
},
"magento2_webpos_productsearch_fulltext_1_v2" : {
"aliases" : {
"magento2_webpos_productsearch_fulltext_1" : { }
}
},
"magento2staging_webpos_productsearch_fulltext_3_v3" : {
"aliases" : {
"magento2staging_webpos_productsearch_fulltext_3" : { }
}
},
"magento2staging_product_2_v3" : {
"aliases" : {
"magento2staging_product_2" : { }
}
},
"magento2_webpos_productsearch_fulltext_2_v2" : {
"aliases" : {
"magento2_webpos_productsearch_fulltext_2" : { }
}
},
"magento2_webpos_productsearch_fulltext_5_v2" : {
"aliases" : {
"magento2_webpos_productsearch_fulltext_5" : { }
}
},
"magento2staging_webpos_productsearch_fulltext_2_v3" : {
"aliases" : {
"magento2staging_webpos_productsearch_fulltext_2" : { }
}
},
"magento2_product_2_v2" : {
"aliases" : {
"magento2_product_2" : { }
}
},
"magento2_product_3_v2" : {
"aliases" : {
"magento2_product_3" : { }
}
},
"magento2staging_product_1_v3" : {
"aliases" : {
"magento2staging_product_1" : { }
}
},
"magento2staging_webpos_productsearch_fulltext_5_v3" : {
"aliases" : {
"magento2staging_webpos_productsearch_fulltext_5" : { }
}
}
}

 

 

 

3 REPLIES 3

Re: Elasticsearch CRITICAL errors - products disappear from categories

I'm curious about this problem, have the same issue, today 2 times elasticsearch crashed.

Re: Elasticsearch CRITICAL errors - products disappear from categories

We're experiencing basically the same error related to index_not_found_exception, appearing randomly in our logs and breaking products indicization:

(Elastic\\Elasticsearch\\Exception\\ClientResponseException(code: 404): 404 Not Found: {\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"},\"status\":404} at /var/www/magento/vendor/elasticsearch/elasticsearch/src/Response/Elasticsearch.php:65)"} []
[2023-12-04T15:48:40.404681+00:00] main.CRITICAL: Elastic\Elasticsearch\Exception\ClientResponseException: 404 Not Found: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"}],"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"},"status":404} in /var/www/magento/vendor/elasticsearch/elasticsearch/src/Response/Elasticsearch.php:65
Stack trace:
#0 /var/www/magento/vendor/elasticsearch/elasticsearch/src/Client.php(172): Elastic\Elasticsearch\Response\Elasticsearch->setResponse()
#1 /var/www/magento/vendor/elasticsearch/elasticsearch/src/Traits/ClientEndpointsTrait.php(1567): Elastic\Elasticsearch\Client->sendRequest()
#2 /var/www/magento/vendor/magento/module-elasticsearch-8/Model/Client/Elasticsearch.php(371): Elastic\Elasticsearch\Client->search()
#3 /var/www/magento/vendor/magento/module-elasticsearch/SearchAdapter/Dynamic/DataProvider.php(182): Magento\Elasticsearch8\Model\Client\Elasticsearch->query()
#4 /var/www/magento/vendor/magento/framework/Search/Dynamic/Algorithm/Improved.php(54): Magento\Elasticsearch\SearchAdapter\Dynamic\DataProvider->getAggregations()
#5 /var/www/magento/vendor/magento/module-elasticsearch/SearchAdapter/Aggregation/Builder/Dynamic.php(48): Magento\Framework\Search\Dynamic\Algorithm\Improved->getItems()
#6 /var/www/magento/vendor/magento/module-elasticsearch/SearchAdapter/Aggregation/Builder.php(90): Magento\Elasticsearch\SearchAdapter\Aggregation\Builder\Dynamic->build()
#7 /var/www/magento/vendor/magento/module-elasticsearch-8/SearchAdapter/Adapter.php(120): Magento\Elasticsearch\SearchAdapter\Aggregation\Builder->build()
#8 /var/www/magento/vendor/magento/module-search/Model/SearchEngine.php(42): Magento\Elasticsearch8\SearchAdapter\Adapter->query()
#9 /var/www/magento/vendor/magento/framework/Search/Search.php(85): Magento\Search\Model\SearchEngine->search()
#10 /var/www/magento/vendor/magento/module-catalog-graph-ql/Model/Resolver/Products/Query/Search.php(133): Magento\Framework\Search\Search->search()
#11 /var/www/magento/vendor/magento/module-catalog-graph-ql/Model/Resolver/Products.php(59): Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search->getResult()
#12 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\CatalogGraphQl\Model\Resolver\Products->resolve()
#13 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\CatalogGraphQl\Model\Resolver\Products\Interceptor->___callParent()
#14 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\CatalogGraphQl\Model\Resolver\Products\Interceptor->Magento\Framework\Interception\{closure}()
#15 /var/www/magento/generated/code/Magento/CatalogGraphQl/Model/Resolver/Products/Interceptor.php(23): Magento\CatalogGraphQl\Model\Resolver\Products\Interceptor->___callPlugins()
#16 /var/www/magento/vendor/magento/framework/GraphQl/Query/Resolver/PromiseFactory.php(63): Magento\CatalogGraphQl\Model\Resolver\Products\Interceptor->resolve()
#17 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(714): Magento\Framework\GraphQl\Query\Resolver\PromiseFactory->Magento\Framework\GraphQl\Query\Resolver\{closure}()
#18 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(632): GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError()
#19 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1317): GraphQL\Executor\ReferenceExecutor->resolveField()
#20 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(298): GraphQL\Executor\ReferenceExecutor->executeFields()
#21 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(237): GraphQL\Executor\ReferenceExecutor->executeOperation()
#22 /var/www/magento/vendor/webonyx/graphql-php/src/Executor/Executor.php(159): GraphQL\Executor\ReferenceExecutor->doExecute()
#23 /var/www/magento/vendor/webonyx/graphql-php/src/GraphQL.php(163): GraphQL\Executor\Executor::promiseToExecute()
#24 /var/www/magento/vendor/webonyx/graphql-php/src/GraphQL.php(97): GraphQL\GraphQL::promiseToExecute()
#25 /var/www/magento/vendor/magento/framework/GraphQl/Query/QueryProcessor.php(83): GraphQL\GraphQL::executeQuery()
#26 /var/www/magento/vendor/magento/module-graph-ql/Controller/GraphQl.php(195): Magento\Framework\GraphQl\Query\QueryProcessor->process()
#27 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\GraphQl\Controller\GraphQl->dispatch()
#28 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\GraphQl\Controller\GraphQl\Interceptor->___callParent()
#29 /var/www/magento/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception\{closure}()
#30 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#31 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception\{closure}()
#32 /var/www/magento/generated/code/Magento/GraphQl/Controller/GraphQl/Interceptor.php(23): Magento\GraphQl\Controller\GraphQl\Interceptor->___callPlugins()
#33 /var/www/magento/vendor/magento/framework/App/Http.php(116): Magento\GraphQl\Controller\GraphQl\Interceptor->dispatch()
#34 /var/www/magento/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#35 /var/www/magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#36 {main} {"exception":"[object] (Elastic\\Elasticsearch\\Exception\\ClientResponseException(code: 404): 404 Not Found: {\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index 

Re: Elasticsearch CRITICAL errors - products disappear from categories

Hi

At the time of the original post our server people:

' could see that the JVM heap size was set to 2GB previously. I have now increased the size to 6GB and this should resolve the issue. '

Since then we have not has any issues, although they also:

'set up an ElasticSearch monitoring script on your server to ensure that your ElasticSearch service is always up and running. This script will monitor ElasticSearch every minute and restart the service if it goes down.'

... so ElasticSearch may be going down periodically and being restarted.

Hope that helps.