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

cloud_roles: Fix metrics lifetime #11155

Merged

Conversation

BenPope
Copy link
Member

@BenPope BenPope commented Jun 1, 2023

Limit the lifetime of the metrics to the async lifetime of refresh_credentials.

Fixes #11095
Fixes #11107

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.1.x
  • v22.3.x
  • v22.2.x

No occurrences on v23.1.x in the last 14d / 55 runs.

Release Notes

  • none

Limit the lifetime of the metrics to the async lifetime of
`refresh_credentials`.

Fixes redpanda-data#11095
Fixes redpanda-data#11107

Signed-off-by: Ben Pope <ben@redpanda.com>
@BenPope BenPope added the area/cloud-storage Shadow indexing subsystem label Jun 1, 2023
@BenPope BenPope requested a review from rockwotj June 1, 2023 21:04
@BenPope BenPope self-assigned this Jun 1, 2023
Copy link
Contributor

@rockwotj rockwotj left a comment

Choose a reason for hiding this comment

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

LGTM, I am going to do some tests to see if this issue exists on 23.1 or not as well.

@BenPope
Copy link
Member Author

BenPope commented Jun 1, 2023

LGTM, I am going to do some tests to see if this issue exists on 23.1 or not as well.

No occurrences on v23.1.x in the last 14d / 55 runs.

@BenPope
Copy link
Member Author

BenPope commented Jun 1, 2023

Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

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

lgtm

@piyushredpanda piyushredpanda merged commit f5de480 into redpanda-data:dev Jun 2, 2023
@rockwotj
Copy link
Contributor

rockwotj commented Jun 2, 2023

Okay so I tracked this down and it's due to the move constructor being invoked on the probe here

This causes the this pointer in the lambda that is created to be invalid, but the metrics are moved so that doesn't explode.

I'm going to post a note to the team about probe lifetimes and then also do a pass of disabling the move constructors for probes and see what breaks.

AFAIK this bug has always been there, but maybe clang's sanitizers only got good enough to recognize it after the clang16 upgrade?

rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
@dotnwat
Copy link
Member

dotnwat commented Jun 2, 2023

I'm going to post a note to the team about probe lifetimes and then also do a pass of disabling the move constructors for probes and see what breaks.

Thanks @rockwotj good idea

AFAIK this bug has always been there, but maybe clang's sanitizers only got good enough to recognize it after the clang16 upgrade?

Yeh I think that is a reasonable hypothesis.

rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
@piyushredpanda
Copy link
Contributor

Thank you, gentlemen!

rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 2, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 3, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 5, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
rockwotj added a commit to rockwotj/redpanda that referenced this pull request Jun 12, 2023
Probes register metrics by capturing `this`, and it's not save to move
them after that. In a lot of places this is safe because their lifetime
is directly tied to a service which lives the whole program's lifetime,
but any small move of that object even during initialization can break
things (see redpanda-data#11155, redpanda-data#11095, redpanda-data#11107).

This takes a big hammer approach to removing this foot gun by making all
probes immovable and wrapping them in `std::unique_ptr`.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cloud-storage Shadow indexing subsystem area/redpanda
Projects
None yet
4 participants