Skip to content

Commit c1c23b4

Browse files
authored
Add logs to debug NoSuchFileException during segments upload (#8475)
Signed-off-by: Ashish Singh <ssashish@amazon.com>
1 parent eca5a6c commit c1c23b4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,17 @@ private synchronized void syncSegments(boolean isRetry) {
224224
// Each metadata file in the remote segment store represents a commit and the following
225225
// statement keeps sure that each metadata will always contain all the segments from last commit + refreshed
226226
// segments.
227-
localSegmentsPostRefresh.addAll(SegmentInfos.readCommit(storeDirectory, latestSegmentInfos.get()).files(true));
227+
SegmentInfos segmentCommitInfos;
228+
try {
229+
segmentCommitInfos = SegmentInfos.readCommit(storeDirectory, latestSegmentInfos.get());
230+
} catch (Exception e) {
231+
// Seeing discrepancy in segment infos and files on disk. SegmentInfosSnapshot is returning
232+
// a segment_N file which does not exist on local disk.
233+
logger.error("Exception occurred while SegmentInfos.readCommit(..)", e);
234+
logger.error("segmentInfosFiles={} diskFiles={}", localSegmentsPostRefresh, storeDirectory.listAll());
235+
throw e;
236+
}
237+
localSegmentsPostRefresh.addAll(segmentCommitInfos.files(true));
228238
segmentInfosFiles.stream()
229239
.filter(file -> !file.equals(latestSegmentInfos.get()))
230240
.forEach(localSegmentsPostRefresh::remove);

0 commit comments

Comments
 (0)