Suppress warning from background sync on relocated primary
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
Relates
Relates
@@ -64,6 +64,7 @@ import org.elasticsearch.index.shard.IndexingOperationListener;
import org.elasticsearch.index.shard.SearchOperationListener;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardNotFoundException;
+import org.elasticsearch.index.shard.ShardNotInPrimaryModeException;
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.index.store.DirectoryService;
@@ -798,14 +799,11 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
case STARTED:
try {
shard.runUnderPrimaryPermit(
- () -> {
- if (shard.isRelocatedPrimary() == false) {
- sync.accept(shard);
- }
- },
+ () -> sync.accept(shard),
e -> {
if (e instanceof AlreadyClosedException == false
- && e instanceof IndexShardClosedException == false) {
+ && e instanceof IndexShardClosedException == false
+ && e instanceof ShardNotInPrimaryModeException == false) {
logger.warn(
new ParameterizedMessage(
"{} failed to execute {} sync", shard.shardId(), source), e);
