#23204·OpenSearch

[BUG] Adaptive Replica Selection can persistently prefer a reconnected / restarted data node with DFS_QUERY_THEN_FETCH and dedicated coordinators

Author: p1trsonCreated Oct 1, 2026Updated Oct 1, 2026
LabelsbuguntriagedSearch:Performance

Describe the bug

Describe the bug

We are observing a reproducible Adaptive Replica Selection (ARS) routing imbalance in OpenSearch 3.7.0 after a data node disconnects/restarts and subsequently rejoins the cluster.

After the restarted data node becomes available for search again, ARS starts routing a disproportionately large fraction of shard-level searches to that node.

The imbalance persists.

Disabling ARS immediately restores an approximately balanced shard-query distribution. Re-enabling ARS immediately restores the preference for the affected node.

Restarting the affected data node does not resolve the condition.

Rolling-restarting the dedicated coordinating-only nodes resolves the condition while ARS remains enabled.

We have now observed this independently with multiple data nodes.

Our workload is almost entirely DFS_QUERY_THEN_FETCH.

Environment

OpenSearch:

Version: 3.7.0
Build hash: 72121f014083f9ca010fd5a7da83b2ec4886027f
Lucene: 10.4.0
OS running on K8s with Opensearch K8s operator

Cluster topology:

5 dedicated coordinating-only nodes
5 dedicated cluster-manager nodes
12 dedicated data nodes

Main index:

240 primary shards
2 replicas
720 shard copies total
~60 shard copies per data node

Shard allocation is balanced across the 12 data nodes.

Search workload:

almost entirely DFS_QUERY_THEN_FETCH

Adaptive Replica Selection:

cluster.routing.use_adaptive_replica_selection: true

Search replicas are not used:

index.number_of_search_replicas: 0

Previous OpenSearch versions / topology difference

We did not observe this behavior in our previous OpenSearch deployments:

OpenSearch 1.3.19
OpenSearch 2.19.2

However, those clusters had an important topology difference.

In the 1.3.19 and 2.19.2 environments, we did NOT use dedicated coordinating-only nodes.

In the current OpenSearch 3.7.0 environment, application searches are sent through a tier of 5 dedicated coordinating-only nodes.

We initially suspected that the behavior might therefore be a regression introduced in OpenSearch 3.x.

However, after comparing the relevant source code across OpenSearch versions, we found that the main pieces involved in our suspected mechanism already existed in 1.3.19 and 2.19.2:

  • statistics for removed nodes are removed from ResponseCollectorService;
  • missing/null ARS ranks are ordered before populated ranks;
  • the DFS search path does not appear to use the same SearchExecutionStatsCollector response wrapper as the normal ShardSearchRequest query path.

We therefore do NOT currently consider this a confirmed OpenSearch 3.x code regression.

The topology difference may, however, be relevant to why the problem is now readily observable.

With dedicated coordinating-only nodes, a coordinator can remain alive while individual data nodes leave and rejoin. Coordinator-local ARS statistics for the surviving data nodes therefore remain alive across a data-node restart.

This may permit an asymmetric state such as:

coordinator remains alive

    data-0 -> ARS statistics populated
    data-1 -> ARS statistics populated
    data-2 -> ARS statistics populated

data-1 leaves

    data-0 -> ARS statistics populated
    data-1 -> entry removed
    data-2 -> ARS statistics populated

data-1 rejoins

    data-0 -> ARS statistics populated
    data-1 -> ARS statistics missing
    data-2 -> ARS statistics populated

This is exactly the type of state involved in our suspected failure mechanism.

We cannot currently state that dedicated coordinating-only nodes are the reason the issue was not observed on 1.3.19/2.19.2.

However, we believe this topology difference is important and should be included in attempts to reproduce the problem.

Incident 1 - 2026-09-22

One data node (data-7) temporarily became disconnected from the cluster and later returned.

After it returned, its shard-query rate became approximately 3-4x higher than the other data nodes despite balanced shard allocation.

Typical rates during the incident were approximately:

data-7: 3.3k - 4.0k shard queries/s
peers:  0.8k - 1.0k shard queries/s

data-7 contained exactly 60 of the 720 shard copies, i.e. 8.33% of all shard copies.

The node was therefore not hosting substantially more shards than its peers.

Image

Per-shard verification

We took two snapshots of per-shard search statistics and calculated the query-count delta for every shard copy.

For every shard ID for which data-7 contained a copy:

60 / 60 shard IDs

the data-7 copy received more queries during the measurement interval than either of its two alternative copies.

Approximately:

average delta on data-7 copy:       990 queries/shard
average delta on alternative copy:  161 queries/shard

median ratio: ~6.2x

The observed ratios across the individual shard groups ranged approximately from:

4.5x to 14.7x

This rules out the imbalance being caused by one or several hot shards.

The preference occurred across all 60 shard groups for which data-7 was an eligible copy.

ARS on -> off -> on test

While the imbalance was present, we disabled ARS:

PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.use_adaptive_replica_selection": false
  }
}

The shard-query distribution immediately became approximately balanced across the data nodes.

We then restored the default:

PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.use_adaptive_replica_selection": null
  }
}

The same node (data-7) immediately became disproportionately selected again.

Observed behavior:

ARS ON
    -> data-7 strongly preferred

ARS OFF
    -> distribution approximately balanced

ARS ON
    -> data-7 strongly preferred again

This strongly associates the routing imbalance with the ARS selection path.

Restarting data-7 itself did NOT resolve the condition.

After the node returned, the disproportionate routing returned.

Rolling-restarting the coordinating-only nodes DID resolve the condition while ARS remained enabled.

Image

Independent occurrence - 2026-09-30

We subsequently observed the same type of behavior during ordinary data-node pod restarts.

Image

Two data nodes were restarted at different times:

data-1
replacement pod start:
2026-09-30T11:18:06Z

data-6
replacement pod start:
2026-09-30T11:27:40Z
Image

data-1

Immediately before the replacement data-1 pod started, OpenSearch logs contain transport failures including:

2026-09-30T11:17:48Z

NodeNotConnectedException[
  [live-opensearch-v3-data-1][10.253.3.114:9300]
  Node not connected
]

Other cluster members also failed to communicate with the old data-1 process.

The replacement pod started at:

2026-09-30T11:18:06Z

After data-1 became available for search again, its shard-query rate increased from the normal approximately:

0.8k - 1.0k/s

to approximately:

2.8k - 3.3k/s

The other long-running data nodes did not show a comparable increase.

data-6

data-6 was restarted later.

Replacement pod start:

2026-09-30T11:27:40Z

During startup:

2026-09-30T11:29:28.891Z

timed out while waiting for initial discovery state - timeout: 30s

The elected cluster-manager subsequently logged:

2026-09-30T11:29:30.237Z

after [30s] publication of cluster state version [21715]
is still waiting for {live-opensearch-v3-data-6} [...]
[SENT_APPLY_COMMIT]

Shortly afterwards data-6 applied the cluster state.

Its ClusterApplierService reported approximately 30 seconds spent connecting to new nodes.

After data-6 became available, it subsequently also developed disproportionately high shard-query traffic.

We deliberately do not claim that this happened immediately when the Kubernetes pod started. The OpenSearch logs show that cluster integration took longer, and the search-rate increase occurred after the node became usable.

At this stage, the recently restarted data nodes were the nodes separating upward from the normal query-rate distribution.

The dedicated coordinating-only nodes were subsequently rolling-restarted.

After the coordinator restart, the abnormal distribution disappeared and the data-node shard-query rates became substantially more balanced.

ARS remained enabled.

Suspected source-level mechanism

The following is our interpretation of the OpenSearch source code.

The production observations above do not depend on this interpretation being correct.

We have not yet demonstrated the complete mechanism in an isolated test environment, so this section should be considered a hypothesis based on source analysis and the observed production behavior.

1. ResponseCollectorService removes statistics when a node is removed

ResponseCollectorService maintains coordinator-local statistics in:

ConcurrentMap<String, NodeStatistics> nodeIdToStats

clusterChanged() contains:

if (event.nodesRemoved()) {
    for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) {
        removeNode(removedNode.getId());
    }
}

removeNode() removes the corresponding entry from nodeIdToStats.

Consequently, after a data node is removed, a long-lived coordinator can have:

data-0 -> statistics
data-1 -> missing
data-2 -> statistics
...

while retaining statistics for all surviving data nodes.

2. Missing ARS statistics are ordered before populated statistics

IndexShardRoutingTable.NodeRankComparator contains logic equivalent to:

if (shard1rank != null) {
    if (shard2rank != null) {
        return shard1rank.compareTo(shard2rank);
    } else {
        // place non-nulls after null values
        return 1;
    }
} else {
    if (shard2rank != null) {
        // place nulls before non-null values
        return -1;
    } else {
        // Both nodes do not have stats, they are equal
        return 0;
    }
}

Therefore:

missing/null rank < populated rank

for purposes of shard-copy ordering.

Consider a shard with three copies after data-1 has rejoined:

data-1 -> no ARS statistics
data-4 -> populated ARS statistics
data-9 -> populated ARS statistics

The comparator appears to explicitly place the null-ranked data-1 copy ahead of the two copies with populated ranks.

Missing ARS information therefore appears capable of becoming a routing preference rather than merely representing an unknown state.

3. Winning-node adjustment is skipped if the selected node has no stats

After sorting the shard copies, the selected node is subject to an adjustment roughly equivalent to:

Optional<ComputedNodeStats> maybeMinStats =
    nodeStats.get(minNodeId);

if (maybeMinStats.isPresent()) {
    adjustStats(...);

    nodeSearchCounts.compute(
        minNodeId,
        (id, conns) -> conns == null ? 1 : conns + 1
    );
}

If the selected node has no statistics:

maybeMinStats.isPresent() == false

the operations inside this block are skipped.

Therefore a null-ranked node can sort first while the adjustment/search-count update normally applied to a selected node is not performed.

This may contribute to the preference persisting.

4. Normal query execution can populate ResponseCollectorService

SearchExecutionStatsCollector wraps search responses and obtains queue size and service-time information which can be added to the coordinator's ResponseCollectorService.

Its response path can invoke:

collector.addNodeStatistics(
    nodeId,
    queueSize,
    responseDuration,
    serviceTimeEWMA
);

For the normal ShardSearchRequest query path, SearchTransportService.sendExecuteQuery() applies:

final ActionListener handler =
    responseWrapper.apply(connection, listener);

Successful responses through this path can therefore create/update the ARS statistics for a node.

5. DFS_QUERY_THEN_FETCH appears to use different response paths

This is the part we believe may explain why the condition persists under our workload.

SearchTransportService.sendExecuteDfs() uses a ConnectionCountingHandler directly rather than applying:

responseWrapper.apply(connection, listener)

The subsequent DFS query phase sends a QuerySearchRequest.

That sendExecuteQuery(QuerySearchRequest, ...) overload also appears to use a ConnectionCountingHandler directly rather than applying the same response wrapper.

In contrast, the normal ShardSearchRequest query overload explicitly applies the response wrapper.

Our production workload is almost entirely:

DFS_QUERY_THEN_FETCH

If our reading is correct, the following asymmetric state may therefore persist:

rejoined node
    -> ResponseCollectorService entry missing

nodes that remained in cluster
    -> ResponseCollectorService entries populated

The null-rank ordering may then cause the rejoined node to be preferred whenever it is an eligible shard copy.

If the DFS execution path does not repopulate the missing statistics, normal production search traffic may fail to repair the asymmetric state.

Hypothesized failure sequence

Putting the source observations together, our current hypothesis is:

1. All data nodes initially have ARS statistics.

2. One data node disconnects/leaves cluster membership.

3. ResponseCollectorService removes that node's statistics.

4. Statistics for the surviving data nodes remain.

5. The data node rejoins.

6. The rejoined node initially has no ARS statistics.

7. For shard groups containing that node:

       restarted node -> null rank
       replica A      -> calculated rank
       replica B      -> calculated rank

8. NodeRankComparator sorts the null-ranked copy first.

9. The null-ranked node therefore becomes preferentially selected.
  1. Because the selected node has no ComputedNodeStats, the normal selected-node adjustment is skipped.

  2. DFS_QUERY_THEN_FETCH does not appear to pass these responses through SearchExecutionStatsCollector.

  3. The missing statistics may therefore remain missing.

  4. The restarted node continues to receive disproportionate search traffic.

This sequence is consistent with our production observations, but we have not yet proven every step with a controlled isolated reproduction.

Why restarting the affected data node does not fix it

Restarting the affected data node does not reset the coordinator-local statistics for the other data nodes.

The coordinator can simply return to:

affected node -> missing
other nodes   -> populated

when the affected node rejoins.

This is consistent with the September 22 incident, where restarting data-7 did not resolve the routing imbalance.

Why restarting dedicated coordinators appears to fix it

ResponseCollectorService is coordinator-local in-memory state.

Restarting a dedicated coordinator recreates that state.

Instead of:

restarted data node -> missing
other data nodes    -> populated

the new coordinator initially starts without the previous asymmetric history.

When multiple candidates have missing ranks, NodeRankComparator considers them equal.

The active shard list is shuffled before ARS ranking, so there is no single uniquely missing node that is systematically ordered before populated alternatives.

This is consistent with our observation that rolling-restarting the dedicated coordinating-only nodes removes the persistent preference while ARS remains enabled.

Why ARS OFF -> ON does not fix it

Disabling ARS changes the shard-selection path but does not appear to clear ResponseCollectorService.

Consequently:

ARS ON
    -> asymmetric collector state used
    -> affected node preferred

ARS OFF
    -> ARS ranking bypassed
    -> distribution approximately balanced

ARS ON
    -> existing asymmetric collector state used again
    -> same affected node preferred again

This matches our production A/B/A test.

Status in OpenSearch 1.3.19 and 2.19.2

We compared the relevant implementation with our previous OpenSearch versions.

The source-level elements described above appear to already exist in OpenSearch 1.3.19 and 2.19.2.

Therefore we do not currently believe that the basic mechanism was introduced by OpenSearch 3.x.

Nevertheless, we did not observe this production behavior while running those versions.

One significant difference is that those clusters did not have a separate tier of dedicated coordinating-only nodes.

We believe it would therefore be useful to compare reproduction behavior between:

A. searches exclusively through a long-lived dedicated coordinating node

and:

B. searches coordinated by the data nodes

We do not currently know whether this topology difference explains why the condition was not observed in our older deployments.

Status in OpenSearch 3.8 / 3.9

We also reviewed the corresponding implementation in OpenSearch 3.8 and 3.9.

The source paths relevant to the suspected mechanism appear unchanged:

  • ResponseCollectorService still removes statistics for removed nodes;
  • NodeRankComparator still places null/missing ranks before non-null ranks;
  • the selected-node adjustment remains conditional on statistics being present;
  • sendExecuteDfs() still does not appear to apply the SearchExecutionStatsCollector response wrapper;
  • the QuerySearchRequest overload used by the subsequent DFS query phase similarly does not appear to apply that wrapper;
  • the normal ShardSearchRequest query path still applies the wrapper.

We therefore do not see a source change in 3.8 or 3.9 that obviously addresses the suspected mechanism.

We have NOT reproduced the production scenario on 3.8 or 3.9, so this statement is based on source comparison, not runtime testing on those releases.

Suggested reproduction

The reproduction should preferably use a dedicated coordinating-only node, rather than sending searches directly to the data nodes, because this matches the topology in which we currently reproduce the problem.

Suggested minimal topology:

1 dedicated coordinating-only node
3 data nodes

Create an index with enough shards to make routing distribution measurable and:

number_of_replicas: 2

Send ALL test searches exclusively through the dedicated coordinating-only node.

Enable ARS.

Generate sustained searches using:

search_type=dfs_query_then_fetch

First verify that:

GET /_nodes/stats/adaptive_selection

shows statistics for all three data nodes.

Then restart one data node such that it actually disappears from cluster membership before rejoining.

Continue the DFS workload.

Immediately after the node rejoins, repeatedly inspect:

GET /_nodes/stats/adaptive_selection

on the coordinating node.

Expected result if our hypothesis is correct:

restarted node -> missing/empty adaptive-selection statistics
existing nodes -> populated adaptive-selection statistics

At the same time, monitor per-node shard-query counters.

Expected routing behavior:

restarted node receives disproportionately many shard queries
wheneve

Source: opensearch-project/OpenSearch