Fire global checkpoint sync under system context
The global checkpoint sync action should fire under the system context since it is not a user-facing management action. Relates #26984
This commit is contained in:
parent
cee9640c20
commit
f81ee225ff
|
@ -35,6 +35,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
import org.elasticsearch.index.shard.IndexShardClosedException;
|
import org.elasticsearch.index.shard.IndexShardClosedException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
|
@ -80,14 +81,19 @@ public class GlobalCheckpointSyncAction extends TransportReplicationAction<
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateGlobalCheckpointForShard(final ShardId shardId) {
|
public void updateGlobalCheckpointForShard(final ShardId shardId) {
|
||||||
|
final ThreadContext threadContext = threadPool.getThreadContext();
|
||||||
|
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
|
||||||
|
threadContext.markAsSystemContext();
|
||||||
execute(
|
execute(
|
||||||
new Request(shardId),
|
new Request(shardId),
|
||||||
ActionListener.wrap(r -> {}, e -> {
|
ActionListener.wrap(r -> {
|
||||||
|
}, e -> {
|
||||||
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
|
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
|
||||||
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
|
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReplicationResponse newResponseInstance() {
|
protected ReplicationResponse newResponseInstance() {
|
||||||
|
|
Loading…
Reference in New Issue