Skip to content

Commit

Permalink
Do not api refresh unpromotables for fast refresh
Browse files Browse the repository at this point in the history
Currently the TransportShardRefreshAction waits for the unpromotables to
be refreshed in all circumstances where they exist. However, when the
indice is marked as fast_refresh, this is not an expectation. This
commit removes this wait.
  • Loading branch information
Tim-Brooks committed Jun 12, 2023
1 parent e4c5a80 commit 7d6ebe0
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.logging.LogManager;
Expand Down Expand Up @@ -111,21 +112,30 @@ public void onPrimaryOperationComplete(
ActionListener<Void> listener
) {
assert replicaRequest.primaryRefreshResult.refreshed() : "primary has not refreshed";
UnpromotableShardRefreshRequest unpromotableReplicaRequest = new UnpromotableShardRefreshRequest(
indexShardRoutingTable,
replicaRequest.primaryRefreshResult.generation(),
false
);
transportService.sendRequest(
transportService.getLocalNode(),
TransportUnpromotableShardRefreshAction.NAME,
unpromotableReplicaRequest,
new ActionListenerResponseHandler<>(
listener.delegateFailure((l, r) -> l.onResponse(null)),
(in) -> ActionResponse.Empty.INSTANCE,
ThreadPool.Names.REFRESH
)
boolean fastRefresh = IndexSettings.INDEX_FAST_REFRESH_SETTING.get(
clusterService.state().metadata().index(indexShardRoutingTable.shardId().getIndex()).getSettings()
);

// Indices marked with fast refresh do not rely on refreshing the unpromotables
if (fastRefresh) {
listener.onResponse(null);
} else {
UnpromotableShardRefreshRequest unpromotableReplicaRequest = new UnpromotableShardRefreshRequest(
indexShardRoutingTable,
replicaRequest.primaryRefreshResult.generation(),
false
);
transportService.sendRequest(
transportService.getLocalNode(),
TransportUnpromotableShardRefreshAction.NAME,
unpromotableReplicaRequest,
new ActionListenerResponseHandler<>(
listener.delegateFailure((l, r) -> l.onResponse(null)),
(in) -> ActionResponse.Empty.INSTANCE,
ThreadPool.Names.REFRESH
)
);
}
}
}
}

0 comments on commit 7d6ebe0

Please sign in to comment.