Skip to content

Commit

Permalink
more logging around refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Sep 15, 2024
1 parent a9203b1 commit e33d627
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.logging.LogManager;
import org.elasticsearch.logging.Logger;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;

import java.util.concurrent.Executor;

public class PostWriteRefresh {
private static final Logger logger = LogManager.getLogger(PostWriteRefresh.class);

public static final String POST_WRITE_REFRESH_ORIGIN = "post_write_refresh";
public static final String FORCED_REFRESH_AFTER_INDEX = "refresh_flag_index";
Expand Down Expand Up @@ -98,6 +101,7 @@ private static void immediate(IndexShard indexShard, ActionListener<Engine.Refre
}

private static void waitUntil(IndexShard indexShard, Translog.Location location, ActionListener<Boolean> listener) {
logger.info("--> waitUntil {} [{}]", indexShard, location);
if (location != null) {
indexShard.addRefreshListener(location, listener::onResponse);
} else {
Expand All @@ -112,6 +116,7 @@ private void refreshUnpromotables(
boolean forced,
@Nullable TimeValue postWriteRefreshTimeout
) {
logger.info("--> refreshUnpromotables {}, [{}], [{}]", indexShard, location, forced);
Engine engineOrNull = indexShard.getEngineOrNull();
if (engineOrNull == null) {
listener.onFailure(new AlreadyClosedException("Engine closed during refresh."));
Expand All @@ -136,6 +141,7 @@ private void sendUnpromotableRequests(
ActionListener<Boolean> listener,
@Nullable TimeValue postWriteRefreshTimeout
) {
logger.info("--> sendUnpromotableRequests {}, [{}], [{}]", indexShard, generation, wasForced);
UnpromotableShardRefreshRequest unpromotableReplicaRequest = new UnpromotableShardRefreshRequest(
indexShard.getReplicationGroup().getRoutingTable(),
indexShard.getOperationPrimaryTerm(),
Expand All @@ -147,7 +153,10 @@ private void sendUnpromotableRequests(
TransportUnpromotableShardRefreshAction.NAME,
unpromotableReplicaRequest,
TransportRequestOptions.timeout(postWriteRefreshTimeout),
new ActionListenerResponseHandler<>(listener.safeMap(r -> wasForced), in -> ActionResponse.Empty.INSTANCE, refreshExecutor)
new ActionListenerResponseHandler<>(listener.safeMap(r -> {
logger.info("--> response got from unpromotable refresh {}, [{}] [{}]", indexShard, generation, wasForced);
return wasForced;
}), in -> ActionResponse.Empty.INSTANCE, refreshExecutor)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3975,11 +3975,13 @@ && isSearchIdle()
return;
} else {
logger.trace("scheduledRefresh: refresh with source [schedule]");
logger.info("--> scheduledRefresh: refresh with source [schedule]");
engine.maybeRefresh("schedule", l.map(Engine.RefreshResult::refreshed));
return;
}
}
logger.trace("scheduledRefresh: no refresh needed");
logger.info("--> scheduledRefresh: no refresh needed");
engine.maybePruneDeletes(); // try to prune the deletes in the engine if we accumulated some
l.onResponse(false);
});
Expand Down

0 comments on commit e33d627

Please sign in to comment.