Skip to content

Fix panic when updating a remote write queue - #7452

Merged
codesome merged 1 commit into
release-2.19from
fix-panic-rw-update
Jun 26, 2020
Merged

Fix panic when updating a remote write queue#7452
codesome merged 1 commit into
release-2.19from
fix-panic-rw-update

Conversation

@csmarchbanks

Copy link
Copy Markdown
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 <csmarchbanks@gmail.com>
@csmarchbanks
csmarchbanks requested review from beorn7 and cstyan June 24, 2020 14:35

@cstyan cstyan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good catch @csmarchbanks @beorn7 👍

@beorn7 beorn7 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.

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
Copy Markdown
Member Author

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

@codesome

Copy link
Copy Markdown
Member

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

@codesome
codesome merged commit b299aba into release-2.19 Jun 26, 2020
@codesome
codesome deleted the fix-panic-rw-update branch June 26, 2020 06:33
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