From 49ac633d93bc16e8d7f8cd1aec999e02f9a4411b Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Fri, 8 Apr 2022 10:16:02 -0700 Subject: [PATCH] fix _cat/shards api replica output (#2809) Signed-off-by: Poojita Raj --- .../java/org/opensearch/index/engine/InternalEngine.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java index 705b5c1e85734..7859af0e22f64 100644 --- a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java @@ -2379,7 +2379,11 @@ protected SegmentInfos getLastCommittedSegmentInfos() { @Override protected final void writerSegmentStats(SegmentsStats stats) { stats.addVersionMapMemoryInBytes(versionMap.ramBytesUsed()); - stats.addIndexWriterMemoryInBytes(indexWriter.ramBytesUsed()); + long indexWriterMemoryInBytes = 0; + if (!(engineConfig.getIndexSettings().isSegrepEnabled() && engineConfig.isReadOnly())) { + indexWriterMemoryInBytes = indexWriter.ramBytesUsed(); + } + stats.addIndexWriterMemoryInBytes(indexWriterMemoryInBytes); stats.updateMaxUnsafeAutoIdTimestamp(maxUnsafeAutoIdTimestamp.get()); }