Skip to content

Commit a91f09a

Browse files
authored
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 91f7a0e commit a91f09a

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;
@@ -835,14 +836,11 @@ private void sync(final Consumer<IndexShard> sync, final String source) {
835836
case STARTED:
836837
try {
837838
shard.runUnderPrimaryPermit(
838-
() -> {
839-
if (shard.isRelocatedPrimary() == false) {
840-
sync.accept(shard);
841-
}
842-
},
839+
() -> sync.accept(shard),
843840
e -> {
844841
if (e instanceof AlreadyClosedException == false
845-
&& e instanceof IndexShardClosedException == false) {
842+
&& e instanceof IndexShardClosedException == false
843+
&& e instanceof ShardNotInPrimaryModeException == false) {
846844
logger.warn(
847845
new ParameterizedMessage(
848846
"{} failed to execute {} sync", shard.shardId(), source), e);

0 commit comments

Comments
 (0)