Skip to content

Commit 658c9a5

Browse files
committed
Fix critical JSON field collision bug in /_nodes/stats/file_cache API
Problem: PINNED field data overwrites USED field data due to using same JSON key Solution: Use PINNED_IN_BYTES constant for pinned data instead of USED_IN_BYTES This eliminates JSON field collision and ensures correct cache usage reporting in API responses. Signed-off-by: tanishq ranjan <[email protected]>
1 parent 5fc979c commit 658c9a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/src/main/java/org/opensearch/index/store/remote/filecache/FileCacheStats.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static final class Fields {
145145
static final String USED = "used";
146146
static final String PINNED = "pinned";
147147
static final String USED_IN_BYTES = "used_in_bytes";
148+
static final String PINNED_IN_BYTES = "pinned_in_bytes";
148149
static final String EVICTIONS = "evictions";
149150
static final String EVICTIONS_IN_BYTES = "evictions_in_bytes";
150151
static final String REMOVED = "removed";
@@ -159,7 +160,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
159160
builder.startObject(statsType.toString());
160161
builder.humanReadableField(FileCacheStats.Fields.ACTIVE_IN_BYTES, FileCacheStats.Fields.ACTIVE, new ByteSizeValue(getActive()));
161162
builder.humanReadableField(FileCacheStats.Fields.USED_IN_BYTES, FileCacheStats.Fields.USED, new ByteSizeValue(getUsed()));
162-
builder.humanReadableField(FileCacheStats.Fields.USED_IN_BYTES, Fields.PINNED, new ByteSizeValue(getPinnedUsage()));
163+
builder.humanReadableField(FileCacheStats.Fields.PINNED_IN_BYTES, Fields.PINNED, new ByteSizeValue(getPinnedUsage()));
163164
builder.humanReadableField(
164165
FileCacheStats.Fields.EVICTIONS_IN_BYTES,
165166
FileCacheStats.Fields.EVICTIONS,

0 commit comments

Comments
 (0)