Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when updating a remote write queue #7452

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

csmarchbanks
Copy link
Member

Right now Queue Manager metrics are registered when the metrics struct
is created, which happens before a changed queue is shutdown and the old
metrics are unregistered. In the case of named queues or updates to
external labels the apply config will panic due to duplicate metrics.

Instead, register the metrics as part of starting the queue as we always
guarantee that Stop will be called before a new Start.

cc: @codesome as this will need a new patch release.

Fixes #7451

Right now Queue Manager metrics are registered when the metrics struct
is created, which happens before a changed queue is shutdown and the old
metrics are unregistered. In the case of named queues or updates to
external labels the apply config will panic due to duplicate metrics.

Instead, register the metrics as part of starting the queue as we always
guarantee that Stop will be called before a new Start.

Signed-off-by: Chris Marchbanks <[email protected]>
Copy link
Member

@cstyan cstyan left a comment

Choose a reason for hiding this comment

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

good catch @csmarchbanks @beorn7 👍

Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Cool. Thank you very much.

To provide context to other reviewers (if any): The problematic code is in write.go. In https://github.com/prometheus/prometheus/blob/master/storage/remote/write.go#L141 , we created and registered the new metrics before we stopped the old queues in https://github.com/prometheus/prometheus/blob/master/storage/remote/write.go#L160 (when unregistering happens). By moving the registering into Start, things work out in the right order, see https://github.com/prometheus/prometheus/blob/master/storage/remote/write.go#L164

@csmarchbanks
Copy link
Member Author

I am going to let @codesome merge this as it is into release-2.19

@codesome
Copy link
Member

Oh I missed the message about release patch :) I will do it today then

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.

4 participants