Skip to content

Commit 29cf87f

Browse files
committed
Fix issue of red index on close for remote enabled clusters
Signed-off-by: Ashish Singh <[email protected]>
1 parent a1d5a87 commit 29cf87f

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private void executeShardOperation(final ShardRequest request, final IndexShard
160160
// to the primary (we call this phase1), and phase2 can then use the fact that the global checkpoint has moved to the maximum
161161
// sequence number to pass the verifyShardBeforeIndexClosing check and create a safe commit where the maximum sequence number
162162
// is equal to the global checkpoint.
163-
indexShard.sync();
163+
indexShard.sync(true);
164164
} else {
165165
indexShard.verifyShardBeforeIndexClosing();
166166
indexShard.flush(new FlushRequest().force(true).waitIfOngoing(true));

server/src/main/java/org/opensearch/index/shard/IndexShard.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4507,8 +4507,12 @@ public final void sync(Translog.Location location, Consumer<Exception> syncListe
45074507
}
45084508

45094509
public void sync() throws IOException {
4510+
sync(false);
4511+
}
4512+
4513+
public void sync(boolean force) throws IOException {
45104514
verifyNotClosed();
4511-
getEngine().translogManager().syncTranslog();
4515+
getEngine().translogManager().syncTranslog(force);
45124516
}
45134517

45144518
/**

server/src/main/java/org/opensearch/index/translog/InternalTranslogManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ public boolean ensureTranslogSynced(Stream<Translog.Location> locations) throws
195195
*/
196196
@Override
197197
public void syncTranslog() throws IOException {
198-
translog.sync();
198+
syncTranslog(false);
199+
}
200+
201+
@Override
202+
public void syncTranslog(boolean force) throws IOException {
203+
translog.sync(force);
199204
translogEventListener.onAfterTranslogSync();
200205
}
201206

server/src/main/java/org/opensearch/index/translog/NoOpTranslogManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public boolean ensureTranslogSynced(Stream<Translog.Location> locations) {
7272
@Override
7373
public void syncTranslog() throws IOException {}
7474

75+
@Override
76+
public void syncTranslog(boolean force) throws IOException {}
77+
7578
@Override
7679
public TranslogStats getTranslogStats() {
7780
return translogStats;

server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,12 @@ private boolean syncToDisk() throws IOException {
463463

464464
@Override
465465
public void sync() throws IOException {
466-
if (syncToDisk() || syncNeeded()) {
466+
sync(false);
467+
}
468+
469+
@Override
470+
public void sync(boolean force) throws IOException {
471+
if (syncToDisk() || syncNeeded() || force) {
467472
prepareAndUpload(primaryTermSupplier.getAsLong(), null);
468473
}
469474
}

server/src/main/java/org/opensearch/index/translog/Translog.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,13 @@ private Closeable acquireTranslogGenFromDeletionPolicy(long viewGen) {
751751
* Sync's the translog.
752752
*/
753753
public void sync() throws IOException {
754+
sync(false);
755+
}
756+
757+
/**
758+
* Sync's the translog.
759+
*/
760+
public void sync(boolean ignored) throws IOException {
754761
try (ReleasableLock lock = readLock.acquire()) {
755762
if (closed.get() == false) {
756763
current.sync();

server/src/main/java/org/opensearch/index/translog/TranslogManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public interface TranslogManager {
5858
*/
5959
void syncTranslog() throws IOException;
6060

61+
/**
62+
* Syncs translog with option to force sync
63+
* @throws IOException the exception while performing the sync operation
64+
*/
65+
void syncTranslog(boolean force) throws IOException;
66+
6167
/**
6268
* Translog operation stats
6369
* @return the translog stats

0 commit comments

Comments
 (0)