Skip to content

Commit f81ee22

Browse files
authored
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
1 parent cee9640 commit f81ee22

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncAction.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.cluster.service.ClusterService;
3636
import org.elasticsearch.common.inject.Inject;
3737
import org.elasticsearch.common.settings.Settings;
38+
import org.elasticsearch.common.util.concurrent.ThreadContext;
3839
import org.elasticsearch.index.shard.IndexShard;
3940
import org.elasticsearch.index.shard.IndexShardClosedException;
4041
import org.elasticsearch.index.shard.ShardId;
@@ -80,13 +81,18 @@ public GlobalCheckpointSyncAction(
8081
}
8182

8283
public void updateGlobalCheckpointForShard(final ShardId shardId) {
83-
execute(
84-
new Request(shardId),
85-
ActionListener.wrap(r -> {}, e -> {
86-
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
87-
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
88-
}
89-
}));
84+
final ThreadContext threadContext = threadPool.getThreadContext();
85+
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
86+
threadContext.markAsSystemContext();
87+
execute(
88+
new Request(shardId),
89+
ActionListener.wrap(r -> {
90+
}, e -> {
91+
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
92+
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
93+
}
94+
}));
95+
}
9096
}
9197

9298
@Override

0 commit comments

Comments
 (0)