Skip to content

Commit

Permalink
Fire global checkpoint sync under system context
Browse files Browse the repository at this point in the history
The global checkpoint sync action should fire under the system context
since it is not a user-facing management action.

Relates #26984
  • Loading branch information
jasontedor authored Oct 12, 2017
1 parent cee9640 commit f81ee22
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardClosedException;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -80,13 +81,18 @@ public GlobalCheckpointSyncAction(
}

public void updateGlobalCheckpointForShard(final ShardId shardId) {
execute(
new Request(shardId),
ActionListener.wrap(r -> {}, e -> {
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
}
}));
final ThreadContext threadContext = threadPool.getThreadContext();
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
threadContext.markAsSystemContext();
execute(
new Request(shardId),
ActionListener.wrap(r -> {
}, e -> {
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
}
}));
}
}

@Override
Expand Down

0 comments on commit f81ee22

Please sign in to comment.