Skip to content

Commit 342c645

Browse files
authored
Fix red index on close for remote enabled clusters (#17521)
Signed-off-by: Ashish Singh <ssashish@amazon.com>
1 parent 3966ed9 commit 342c645

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.lucene.store.Directory;
4141
import org.apache.lucene.store.Lock;
4242
import org.opensearch.Version;
43+
import org.opensearch.cluster.metadata.IndexMetadata;
4344
import org.opensearch.common.concurrent.GatedCloseable;
4445
import org.opensearch.common.lucene.Lucene;
4546
import org.opensearch.common.lucene.index.OpenSearchDirectoryReader;
@@ -166,7 +167,7 @@ public ReadOnlyEngine(
166167
}
167168

168169
protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStats) {
169-
if (requireCompleteHistory == false) {
170+
if (requireCompleteHistory == false || isClosedRemoteIndex()) {
170171
return;
171172
}
172173
// Before 3.0 the global checkpoint is not known and up to date when the engine is created after
@@ -187,6 +188,14 @@ protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStat
187188
}
188189
}
189190

191+
/**
192+
* Returns true if this is a remote store index (included if migrating as well) which is closed.
193+
*/
194+
private boolean isClosedRemoteIndex() {
195+
return this.engineConfig.getIndexSettings().isAssignedOnRemoteNode()
196+
&& this.engineConfig.getIndexSettings().getIndexMetadata().getState() == IndexMetadata.State.CLOSE;
197+
}
198+
190199
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
191200
assert maxSeqNo == globalCheckpoint : "max seq. no. [" + maxSeqNo + "] does not match [" + globalCheckpoint + "]";
192201
return true;

0 commit comments

Comments
 (0)