Skip to content

Commit

Permalink
Do not refresh unpromotables when fast_refresh set (elastic#96753)
Browse files Browse the repository at this point in the history
Currently, unpromotables are not relevant when the index is set to
fast_refresh. Therefore, we should not wait on their refresh on
wait_until and immediate.
  • Loading branch information
Tim-Brooks committed Jun 12, 2023
1 parent e3a6bb6 commit e4c5a80
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.translog.Translog;
Expand Down Expand Up @@ -47,7 +48,9 @@ public void refreshShard(
case WAIT_UNTIL -> waitUntil(indexShard, location, new ActionListener<>() {
@Override
public void onResponse(Boolean forced) {
if (indexShard.routingEntry().isSearchable() == false && location != null) {
// Fast refresh indices do not depend on the unpromotables being refreshed
boolean fastRefresh = IndexSettings.INDEX_FAST_REFRESH_SETTING.get(indexShard.indexSettings().getSettings());
if (location != null && (indexShard.routingEntry().isSearchable() == false && fastRefresh == false)) {
refreshUnpromotables(indexShard, location, listener, forced, postWriteRefreshTimeout);
} else {
listener.onResponse(forced);
Expand All @@ -62,7 +65,9 @@ public void onFailure(Exception e) {
case IMMEDIATE -> immediate(indexShard, new ActionListener<>() {
@Override
public void onResponse(Engine.RefreshResult refreshResult) {
if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0) {
// Fast refresh indices do not depend on the unpromotables being refreshed
boolean fastRefresh = IndexSettings.INDEX_FAST_REFRESH_SETTING.get(indexShard.indexSettings().getSettings());
if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0 && fastRefresh == false) {
sendUnpromotableRequests(indexShard, refreshResult.generation(), true, listener, postWriteRefreshTimeout);
} else {
listener.onResponse(true);
Expand Down

0 comments on commit e4c5a80

Please sign in to comment.