Open
Description
We had a scenario where the elastic search server had 100% memory utilization. This caused a downtime of the entire shop, even if the elasticsearch is not required for product-detail page, cart, checkout.
Root cause was, that all the php-fpm workers were blocked because elasticsearch requests were not timed out.
Preconditions and environment
- Magento version 2.4.6-p3
- Incredibly slow / stuck elasticsearch (e.g. due to 100% server memory utilization)
Steps to reproduce
- It might not be reproducible with @magento provided dev instance
- With docker, you can pause the elasticsearch docker container. It is not reproducible when docker container is stopped!
Expected result
Configured elasticsearch timeout kicks in and cancels the request
Actual result
Request is executed until php max_execution_time is exceeded
Additional information
I developed a hotfix-patch for this, which can be used as base for a final solution. With this, it works as expected:
===================================================================
diff --git a/vendor/magento/module-elasticsearch-7/SearchAdapter/Mapper.php b/vendor/magento/module-elasticsearch-7/SearchAdapter/Mapper.php
--- a/vendor/magento/module-elasticsearch-7/SearchAdapter/Mapper.php
+++ b/vendor/magento/module-elasticsearch-7/SearchAdapter/Mapper.php (date 1702503910793)
@@ -39,6 +39,8 @@
{
$searchQuery = $this->mapper->buildQuery($request);
$searchQuery['track_total_hits'] = true;
+ $searchQuery['client']['timeout'] = 2;
+ $searchQuery['client']['connect_timeout'] = 0.5;
return $searchQuery;
}
}
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.