Skip to content

HDDS-16694. Count only loaded snapshots in NumSnapshotCacheSize - #11400

Open
rjgoyln wants to merge 1 commit into
apache:masterfrom
rjgoyln:HDDS-16694
Open

rjgoyln wants to merge 1 commit into
apache:masterfrom
rjgoyln:HDDS-16694

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Reading a snapshot that has already been purged makes the cache loader fail with FILE_NOT_FOUND. SnapshotCache.get creates no cache entry in that case, yet still incremented NumSnapshotCacheSize. Both decrements require an entry, so each such read left the JMX gauge one higher than the real cache size for good.

The gauge is now incremented only once the loader returns a snapshot.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16694

How was this patch tested?

The new TestSnapshotCache#testGetInactiveSnapshotDoesNotIncrementCacheSize fails on master (expected: <0> but was: <1>) and passes with the change; the other 27 tests in the class still pass.

Generated-by: Claude Code (Opus 5.5)

Reading a snapshot that was already purged makes the cache loader fail
with FILE_NOT_FOUND, so no cache entry is created, yet the gauge was
still incremented. Every decrement requires a cached entry, so each such
read left the gauge permanently one higher than the real cache size.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 17:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rjgoyln
rjgoyln marked this pull request as ready for review October 3, 2026 17:27
@github-actions github-actions Bot added the om label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants