Fix duplicate metric registration during concurrent pipeline state builds #26187
Open
patrickmann wants to merge 2 commits into
Open
Fix duplicate metric registration during concurrent pipeline state builds #26187patrickmann wants to merge 2 commits into
patrickmann wants to merge 2 commits into
Conversation
…ilds (#26080) Synchronize the remove+register metric sequence in PipelineInterpreter.State to prevent concurrent State constructions from racing on the shared MetricRegistry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses noisy Duplicate metric set registered ERROR logs caused by a race during concurrent construction of PipelineInterpreter.State, where cache metrics were removed and re-registered via a non-atomic sequence.
Changes:
- Add a static lock in
PipelineInterpreter.Stateto synchronize the metricremoveMatching+safelyRegisterAllcompound operation. - Add a concurrent regression test intended to exercise concurrent
Stateconstruction. - Add an unreleased changelog entry for issue #26080.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/processors/PipelineInterpreter.java |
Serializes cache metric remove+register to prevent concurrent duplicate registrations/log spam. |
graylog2-server/src/test/java/org/graylog/plugins/pipelineprocessor/processors/StateTest.java |
Adds a concurrent construction regression test and switches to MetricRegistry. |
changelog/unreleased/issue-26080.toml |
Records the fix in the unreleased changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #26080
PipelineInterpreter.Stateregisters cache metrics via a non-atomicremoveMatching+safelyRegisterAllsequence. Two independent code paths (PipelineInterpreterStateUpdaterandPipelineMetadataUpdateJob) can constructStateconcurrently, causing Thread B to register metrics between Thread A's remove and register. This results in noisy ERROR logs:Duplicate metric set registered.The fix adds a static lock to synchronize the compound remove+register operation. This is acceptable since updates are relatively infrequent.
How Tested
Added concurrent regression test
StateTest.concurrentStateConstructionDoesNotCauseDuplicateMetricErrorsManual test: deploy to a test environment, trigger rapid pipeline config changes (e.g. bulk rule updates), verify no "Duplicate metric set registered" ERROR in server logs
Types of changes
Checklist: