Skip to content

Commit 90f5525

Browse files
committed
Suppress warning from background sync on relocated primary (#46247)
If a primary as being relocated, then the global checkpoint and retention lease background sync can emit unnecessary warning logs. This side effect was introduced in #42241. Relates #40800 Relates #42241
1 parent 8fb6cbd commit 90f5525

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

server/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.elasticsearch.index.shard.SearchOperationListener;
6868
import org.elasticsearch.index.shard.ShardId;
6969
import org.elasticsearch.index.shard.ShardNotFoundException;
70+
import org.elasticsearch.index.shard.ShardNotInPrimaryModeException;
7071
import org.elasticsearch.index.shard.ShardPath;
7172
import org.elasticsearch.index.similarity.SimilarityService;
7273
import org.elasticsearch.index.store.Store;
@@ -839,14 +840,11 @@ private void sync(final Consumer<IndexShard> sync, final String source) {
839840
case STARTED:
840841
try {
841842
shard.runUnderPrimaryPermit(
842-
() -> {
843-
if (shard.isRelocatedPrimary() == false) {
844-
sync.accept(shard);
845-
}
846-
},
843+
() -> sync.accept(shard),
847844
e -> {
848845
if (e instanceof AlreadyClosedException == false
849-
&& e instanceof IndexShardClosedException == false) {
846+
&& e instanceof IndexShardClosedException == false
847+
&& e instanceof ShardNotInPrimaryModeException == false) {
850848
logger.warn(
851849
new ParameterizedMessage(
852850
"{} failed to execute {} sync", shard.shardId(), source), e);

0 commit comments

Comments
 (0)