From 86c6e1c6adde31a4af67ead6d57202502336df82 Mon Sep 17 00:00:00 2001 From: Gaurav Bafna Date: Tue, 14 Jan 2025 15:15:55 +0530 Subject: [PATCH] Using RemoteDirectory#delete to clear all segments during migration Signed-off-by: Gaurav Bafna --- server/src/main/java/org/opensearch/index/shard/IndexShard.java | 2 +- .../org/opensearch/index/store/RemoteSegmentStoreDirectory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index eb3999718ca5b..2967cf9c036db 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -5031,7 +5031,7 @@ public void deleteTranslogFilesFromRemoteTranslog() throws IOException { */ public void deleteRemoteStoreContents() throws IOException { deleteTranslogFilesFromRemoteTranslog(); - getRemoteDirectory().deleteStaleSegments(0); + getRemoteDirectory().delete(); } public void syncTranslogFilesFromRemoteTranslog() throws IOException { diff --git a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java index d51fe0643575e..9dae38a41f927 100644 --- a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java @@ -1038,7 +1038,7 @@ private boolean deleteIfEmpty() throws IOException { return delete(); } - private boolean delete() { + public boolean delete() { try { remoteDataDirectory.delete(); remoteMetadataDirectory.delete();