From 0c55963e8a6b8068ddc23ff87f6541532051ee32 Mon Sep 17 00:00:00 2001 From: Ashish Date: Thu, 6 Jul 2023 14:09:41 +0530 Subject: [PATCH] Add logs to debug NoSuchFileException during segments upload (#8475) Signed-off-by: Ashish Singh Signed-off-by: sahil buddharaju --- .../index/shard/RemoteStoreRefreshListener.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java b/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java index ddca12d9283f3..4eef02eeaf380 100644 --- a/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java +++ b/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java @@ -224,7 +224,17 @@ private synchronized void syncSegments(boolean isRetry) { // Each metadata file in the remote segment store represents a commit and the following // statement keeps sure that each metadata will always contain all the segments from last commit + refreshed // segments. - localSegmentsPostRefresh.addAll(SegmentInfos.readCommit(storeDirectory, latestSegmentInfos.get()).files(true)); + SegmentInfos segmentCommitInfos; + try { + segmentCommitInfos = SegmentInfos.readCommit(storeDirectory, latestSegmentInfos.get()); + } catch (Exception e) { + // Seeing discrepancy in segment infos and files on disk. SegmentInfosSnapshot is returning + // a segment_N file which does not exist on local disk. + logger.error("Exception occurred while SegmentInfos.readCommit(..)", e); + logger.error("segmentInfosFiles={} diskFiles={}", localSegmentsPostRefresh, storeDirectory.listAll()); + throw e; + } + localSegmentsPostRefresh.addAll(segmentCommitInfos.files(true)); segmentInfosFiles.stream() .filter(file -> !file.equals(latestSegmentInfos.get())) .forEach(localSegmentsPostRefresh::remove);