Skip to content

[AMORO-4570][Common] Fix metric definition counts on repeated unregistration - #4571

Open
sivakumar-mahalingam wants to merge 1 commit into
apache:masterfrom
sivakumar-mahalingam:fix/4570-repeated-metric-removal
Open

sivakumar-mahalingam wants to merge 1 commit into
apache:masterfrom
sivakumar-mahalingam:fix/4570-repeated-metric-removal

Conversation

@sivakumar-mahalingam

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Unregistering an absent or previously removed metric decrements its definition count even when no metric is removed. This can prematurely remove a definition while other metrics still use it, allowing conflicting definitions with the same name to be registered.

Close #4570.

Brief change log

  • Update MetricRegistry.unregister() to decrement the definition count only when a registered metric is removed.
  • Notify listeners after updating the definition count and only when removal succeeds.
  • Add regression tests covering repeated removal, absent keys, definition reuse, and registration from a removal listener.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Verified with Java 11:

  • ./mvnw -pl amoro-common -Dtest=TestMetricRegistry test - 6 tests passed.
  • ./mvnw -pl amoro-common clean package - 139 tests passed; build succeeded.
  • ./mvnw validate - all 34 modules passed.

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Repeated metric removal corrupts registry definition counts

1 participant