Skip to content

Commit e0532a0

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 09fbf09 commit e0532a0

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
@@ -64,6 +64,7 @@
6464
import org.elasticsearch.index.shard.SearchOperationListener;
6565
import org.elasticsearch.index.shard.ShardId;
6666
import org.elasticsearch.index.shard.ShardNotFoundException;
67+
import org.elasticsearch.index.shard.ShardNotInPrimaryModeException;
6768
import org.elasticsearch.index.shard.ShardPath;
6869
import org.elasticsearch.index.similarity.SimilarityService;
6970
import org.elasticsearch.index.store.DirectoryService;
@@ -798,14 +799,11 @@ private void sync(final Consumer<IndexShard> sync, final String source) {
798799
case STARTED:
799800
try {
800801
shard.runUnderPrimaryPermit(
801-
() -> {
802-
if (shard.isRelocatedPrimary() == false) {
803-
sync.accept(shard);
804-
}
805-
},
802+
() -> sync.accept(shard),
806803
e -> {
807804
if (e instanceof AlreadyClosedException == false
808-
&& e instanceof IndexShardClosedException == false) {
805+
&& e instanceof IndexShardClosedException == false
806+
&& e instanceof ShardNotInPrimaryModeException == false) {
809807
logger.warn(
810808
new ParameterizedMessage(
811809
"{} failed to execute {} sync", shard.shardId(), source), e);

0 commit comments

Comments
 (0)