Skip to content

Commit a835988

Browse files
Fix red index on close for remote enabled clusters (#17521) (#17533)
(cherry picked from commit 342c645) Signed-off-by: Ashish Singh <ssashish@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent f7742c2 commit a835988

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.lucene.store.Lock;
4242
import org.opensearch.LegacyESVersion;
4343
import org.opensearch.Version;
44+
import org.opensearch.cluster.metadata.IndexMetadata;
4445
import org.opensearch.common.concurrent.GatedCloseable;
4546
import org.opensearch.common.lucene.Lucene;
4647
import org.opensearch.common.lucene.index.OpenSearchDirectoryReader;
@@ -180,7 +181,7 @@ public Translog.Operation next() {
180181
}
181182

182183
protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStats) {
183-
if (requireCompleteHistory == false) {
184+
if (requireCompleteHistory == false || isClosedRemoteIndex()) {
184185
return;
185186
}
186187
// Before 8.0 the global checkpoint is not known and up to date when the engine is created after
@@ -205,6 +206,14 @@ protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStat
205206
}
206207
}
207208

209+
/**
210+
* Returns true if this is a remote store index (included if migrating as well) which is closed.
211+
*/
212+
private boolean isClosedRemoteIndex() {
213+
return this.engineConfig.getIndexSettings().isAssignedOnRemoteNode()
214+
&& this.engineConfig.getIndexSettings().getIndexMetadata().getState() == IndexMetadata.State.CLOSE;
215+
}
216+
208217
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
209218
assert maxSeqNo == globalCheckpoint : "max seq. no. [" + maxSeqNo + "] does not match [" + globalCheckpoint + "]";
210219
return true;

0 commit comments

Comments
 (0)