Skip to content

Commit

Permalink
On delete, fallback to earlier logic when pinned timestamp is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Aug 30, 2024
1 parent 096453d commit 2b4092b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.opensearch.index.seqno.SeqNoStats;
import org.opensearch.index.shard.IndexShard;
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase;
Expand Down Expand Up @@ -109,13 +110,16 @@ public void cleanUp() throws Exception {
assertAcked(
client().admin().indices().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get()
);
assertBusy(() -> {
try {
assertEquals(0, getFileCount(translogRepoPath));
} catch (IOException e) {
fail();
}
}, 30, TimeUnit.SECONDS);
// With pinned timestamp, we can have tlog files even after deletion.
if (RemoteStoreSettings.isPinnedTimestampsEnabled() == false) {
assertBusy(() -> {
try {
assertEquals(0, getFileCount(translogRepoPath));
} catch (IOException e) {
fail();
}
}, 30, TimeUnit.SECONDS);
}
super.teardown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,14 @@ public static void cleanup(
protected void onDelete() {
ClusterService.assertClusterOrClusterManagerStateThread();
// clean up all remote translog files
try {
trimUnreferencedReaders(true, false);
} catch (IOException e) {
logger.error("Exception while deleting translog files from remote store", e);
if (RemoteStoreSettings.isPinnedTimestampsEnabled()) {
try {
trimUnreferencedReaders(true, false);
} catch (IOException e) {
logger.error("Exception while deleting translog files from remote store", e);
}

Check warning on line 914 in server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java#L911-L914

Added lines #L911 - L914 were not covered by tests
} else {
translogTransferManager.delete();
}
}

Expand Down

0 comments on commit 2b4092b

Please sign in to comment.