Skip to content

Commit

Permalink
Fix issue of red index on close for remote enabled clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Sep 19, 2024
1 parent a1d5a87 commit 29cf87f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void executeShardOperation(final ShardRequest request, final IndexShard
// to the primary (we call this phase1), and phase2 can then use the fact that the global checkpoint has moved to the maximum
// sequence number to pass the verifyShardBeforeIndexClosing check and create a safe commit where the maximum sequence number
// is equal to the global checkpoint.
indexShard.sync();
indexShard.sync(true);
} else {
indexShard.verifyShardBeforeIndexClosing();
indexShard.flush(new FlushRequest().force(true).waitIfOngoing(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4507,8 +4507,12 @@ public final void sync(Translog.Location location, Consumer<Exception> syncListe
}

public void sync() throws IOException {
sync(false);
}

public void sync(boolean force) throws IOException {
verifyNotClosed();
getEngine().translogManager().syncTranslog();
getEngine().translogManager().syncTranslog(force);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ public boolean ensureTranslogSynced(Stream<Translog.Location> locations) throws
*/
@Override
public void syncTranslog() throws IOException {
translog.sync();
syncTranslog(false);
}

@Override
public void syncTranslog(boolean force) throws IOException {
translog.sync(force);
translogEventListener.onAfterTranslogSync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public boolean ensureTranslogSynced(Stream<Translog.Location> locations) {
@Override
public void syncTranslog() throws IOException {}

@Override
public void syncTranslog(boolean force) throws IOException {}

@Override
public TranslogStats getTranslogStats() {
return translogStats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,12 @@ private boolean syncToDisk() throws IOException {

@Override
public void sync() throws IOException {
if (syncToDisk() || syncNeeded()) {
sync(false);
}

@Override
public void sync(boolean force) throws IOException {
if (syncToDisk() || syncNeeded() || force) {
prepareAndUpload(primaryTermSupplier.getAsLong(), null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,13 @@ private Closeable acquireTranslogGenFromDeletionPolicy(long viewGen) {
* Sync's the translog.
*/
public void sync() throws IOException {
sync(false);
}

/**
* Sync's the translog.
*/
public void sync(boolean ignored) throws IOException {
try (ReleasableLock lock = readLock.acquire()) {
if (closed.get() == false) {
current.sync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public interface TranslogManager {
*/
void syncTranslog() throws IOException;

/**
* Syncs translog with option to force sync
* @throws IOException the exception while performing the sync operation
*/
void syncTranslog(boolean force) throws IOException;

/**
* Translog operation stats
* @return the translog stats
Expand Down

0 comments on commit 29cf87f

Please sign in to comment.