#41045·magento2

Opensearch clients do not apply server_timeout to search queries

Author: damienwebdevCreated Jul 23, 2026Updated Sep 28, 2026
LabelsIssue: ConfirmedComponent: CatalogSearchTriage: Dev.ExperienceReproduced on 2.4.xPriority: P2Progress: ready for groomingArea: CatalogReported on 2.4.7 -p10

Preconditions and environment

  1. Magento 2.4.7-p10 (also reproduces on current 2.4-develop; affected code is unchanged)
  2. PHP 8.3
  3. Catalog Search engine set to opensearch
  4. Library versions: opensearch-project/opensearch-php 2.x, ezimuel/ringphp ^1.4

Steps to reproduce

  1. Configure Catalog Search with the opensearch engine and set Stores > Configuration > Catalog > Catalog Search > OpenSearch Server Timeout to a low value, for example 5.
  2. Cause the search backend to accept a TCP connection but never return a response body. This can be simulated by pointing the engine at a socket that black-holes after connect, or by inducing a transient network partition to the search host while a query is in flight so the peer's FIN/RST is lost and the client is left with a half-open connection.
  3. Issue a storefront search (or any request that triggers \Magento\OpenSearch\Model\SearchClient::query()).

Expected result

  1. The search request is bounded by the configured OpenSearch Server Timeout (server_timeout, default 15s) and fails after that period, freeing the worker.
  2. A misbehaving or unreachable search backend cannot block a request indefinitely.

Actual result

  1. The configured server_timeout is not applied to search queries. It is only applied to ping() / Test Connection.
  2. Search queries fall back to the transport default, which has no overall/read timeout (CURLOPT_TIMEOUT unset = 0 = infinite). The request blocks forever, holding the PHP-FPM worker. Enough such requests exhaust pm.max_children, saturating the pool: new connections queue unaccepted (observed Recv-Q in the hundreds on the FPM listener) and the instance stops serving HTTP even though the search cluster itself has recovered.

Additional information

The configured timeout is read correctly but is only wired to ping(), and the value is silently discarded when the client is built. Validated against magento/[email protected], app/code/Magento/OpenSearch/Model/SearchClient.php.

1. The option is populated (default 15s) — Magento\Elasticsearch\Model\Config::prepareClientOptions() (shared config provider used by the OpenSearch engine):

php
// app/code/Magento/Elasticsearch/Model/Config.php
'timeout' => $this->getElasticsearchConfigData('server_timeout') ?: self::ELASTICSEARCH_DEFAULT_TIMEOUT, // 15

2. Only ping() uses it; query() does not — Magento\OpenSearch\Model\SearchClient:

php
// ping() (L104-111): timeout applied
public function ping(): bool
{
    if ($this->pingResult === null) {
        $this->pingResult = $this->getOpenSearchClient()
            ->ping(['client' => ['timeout' => $this->clientOptions['timeout']]]);
    }
    return $this->pingResult;
}

// query() (L294-297): no 'client' => ['timeout' => ...] passed
public function query(array $query): array
{
    return $this->getOpenSearchClient()->search($query);
}

bulkQuery() (L152-156) and the other data methods likewise pass no timeout.

3. The timeout option is dropped when building the client. getOpenSearchClient() (L97-100) builds the client via ClientBuilder::fromConfig($config, true), where $config comes from buildOSConfig(). buildOSConfig() adds only the hosts key and passes timeout through unchanged; it sets no connectionParams, connect_timeout, or per-request client key, and calls no setTimeout. fromConfig then maps a config key only if a matching setter exists; otherwise, because $quiet = true, it discards the key without error. There is no setTimeout() on ClientBuilder, and timeout is not whitelisted:

php
// vendor/opensearch-project/opensearch-php/src/OpenSearch/ClientBuilder.php
public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader']; // 'timeout' absent
...
$method = in_array($key, self::ALLOWED_METHODS_FROM_CONFIG, true) ? $key : "set$key"; // 'timeout' -> settimeout() (does not exist) -> dropped

So the timeout is placed in the config, threaded through buildOSConfig(), then silently dropped at fromConfig(..., true). No data method re-supplies it per request.

4. The transport has no read timeout. opensearch-project/opensearch-php depends on ezimuel/ringphp, and Magento builds the legacy (RingPHP) client. With nothing passed on the query, requests use RingPHP defaults:

php
// vendor/ezimuel/ringphp/src/Client/CurlFactory.php
CURLOPT_CONNECTTIMEOUT => 150, // connect only
// CURLOPT_TIMEOUT is set only if the caller supplies a 'timeout'; otherwise unset (curl default 0 = infinite)

Suggested fix

Apply the configured timeout to data requests, not just ping(). For example, pass the per-request client option in each data method of OpenSearch\Model\SearchClient:

php
public function query(array $query): array
{
    $query['client']['timeout'] = $this->clientOptions['timeout'];
    return $this->getOpenSearchClient()->search($query);
}

Alternatively, set a default request timeout at client-build time so all requests inherit server_timeout. A separate, explicit connect timeout would also be desirable (currently fixed at RingPHP's 150s). At minimum, the documentation for OpenSearch Server Timeout should state that it currently governs only connection testing, not query execution.

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”.