Skip to content

fix: preserve existing exposition names after registration failures - #2668

Open
yangjj-iso wants to merge 1 commit into
prometheus:mainfrom
yangjj-iso:fix/registry-registration-rollback
Open

yangjj-iso wants to merge 1 commit into
prometheus:mainfrom
yangjj-iso:fix/registry-registration-rollback

Conversation

@yangjj-iso

Copy link
Copy Markdown

Fixes #2667.

After a counter events is registered, rejecting a duplicate registration currently removes the first collector's events_total/events_created reservations. A gauge named events_total can then be registered despite the original counter still being present.

Track only exposition names newly claimed by the current attempt and release only those names on either claim or registration-validation failure. Keep claiming, validation, and rollback inside the existing per-name registered.compute() operation, consistent with unregistration, so concurrent registrations of the same name cannot reuse a claim that another attempt then rolls back. No public API or global lock is added.

Add five regression tests covering duplicate label schemas, conflicting metadata, conflicting types, partial exposition-name conflicts, and failed MultiCollector registration. They also verify that temporary claims are released and normal unregistration still frees the existing names.

Validation:

  • Before the fix: the five new registry tests failed; the existing 27 passed.
  • ./mvnw -pl prometheus-metrics-model -am test -Dcoverage.skip=true passed on Java 25 with default Error Prone/NullAway: 328 tests (model 266, config 62), zero failures/errors/skips.
  • mise run --skip-tools lint:fix passed after applying its formatting changes.
  • mise run --skip-tools build passed on Java 25 across all 56 modules, with -DskipITs appended to MAVEN_ARGS because Docker is unavailable. No build configuration was changed; this task skips unit test execution, so the 328 tests above were run separately.
  • git diff --check and independent review passed. Full test, Docker integration, and native test suites were not run locally.

AI assistance was used to investigate, implement, and test this change.

@fstab

Roll back only names acquired by the current registration attempt.
Keep claims and rollback within the existing per-name registry compute
operation to protect concurrent registrations and unregistration.

Fixes prometheus#2667

Signed-off-by: redyyang <3202137046@qq.com>

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.

Failed registration removes exposition names reserved by existing collectors

1 participant