Skip to content

HDDS-16753. Decrement NumSnapshotDeleted when a snapshot is purged - #11568

Open
chihsuan wants to merge 2 commits into
apache:masterfrom
chihsuan:HDDS-16753
Open

chihsuan wants to merge 2 commits into
apache:masterfrom
chihsuan:HDDS-16753

Conversation

@chihsuan

Copy link
Copy Markdown
Member

What changes were proposed?

Follow-up to HDDS-16719. NumSnapshotDeleted goes up when a snapshot is deleted, but nothing brings it down when SnapshotDeletingService purges that snapshot. On a long-running OM it keeps growing until a restart recounts snapshotInfoTable.

This PR decrements it in OMSnapshotPurgeRequest by the number of SNAPSHOT_DELETED snapshots actually purged, once the request succeeds. Snapshots already gone from the table are skipped, and a failed request leaves the metric unchanged.

JIRA

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

How was this patch tested?

https://github.com/chihsuan/ozone/actions/runs/38748302479

  • testValidateAndUpdateCache keeps one active snapshot and checks only deleted ones are subtracted.
  • testDuplicateSnapshotPurge checks a repeated purge does not decrement twice.
  • Added testNumSnapshotDeletedUnchangedOnPartialPurgeFailure, which fails if the decrement happens inside the loop.

Generated-by: Claude Code (Claude Opus 5.5)

Copilot AI balanced review requested due to automatic review settings October 16, 2026 15:33

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.

🟢 Approval recommended

The focused change matches the intended metric behavior, with regression coverage for success, duplicate purges, and failure.

0 open findings

What changed in this PR

Keeps OM’s NumSnapshotDeleted metric accurate by decrementing it when deleted snapshots are successfully purged.

Changes:

  • Adds a bulk decrement method to OMMetrics.
  • Counts deleted snapshots purged and updates the metric after request success.
  • Tests mixed snapshot states, duplicate purges, and partial failure.
File Description
hadoop-ozone/​ozone-manager/​src/​test/​java/​org/​apache/​hadoop/​ozone/​om/​request/​snapshot/​TestOMSnapshotPurgeRequestAndResponse.java Adds metric regression coverage.
hadoop-ozone/​ozone-manager/​src/​main/​java/​org/​apache/​hadoop/​ozone/​om/​request/​snapshot/​OMSnapshotPurgeRequest.java Decrements the metric after successful purges.
hadoop-ozone/​ozone-manager/​src/​main/​java/​org/​apache/​hadoop/​ozone/​om/​OMMetrics.java Adds the bulk decrement method.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the om label Oct 16, 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