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][broker] Make timestamp fields thread safe by using volatile to prevent visibility issues #17252

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Aug 24, 2022

Motivation

  • fixes issue with stats where timestamps might be inconsistent because of visibility issues
  • most timestamps already are volatile, and it's better to follow this approach to prevent field update visibility issues
  • some visibility issues might only be reproducible on certain hardware platforms (multiple CPU sockets, multiple NUMA nodes, etc.) so one cannot be sure about the behavior unless code is made thread safe

Modifications

  • make fields volatile

Additional context

In Pulsar code base some stats intentionally don't use volatile as explained by @merlimat in this comment. The goal of this PR is to ensure consistently by deliberately making the fields volatile and not to rely on "best efforts" type of stats.

  • doc-not-needed

@lhotari lhotari added type/bug The PR fixed a bug or issue reported a bug area/broker doc-not-needed Your PR changes do not impact docs labels Aug 24, 2022
Copy link
Member

@michaeljmarshall michaeljmarshall 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 know this is a break from the previous order, but I think it is important for the correctness of the metrics, which are important for verifying the system's correctness.

@github-actions github-actions bot added doc-label-missing and removed doc-not-needed Your PR changes do not impact docs labels Aug 24, 2022
@github-actions
Copy link

@lhotari Please provide a correct documentation label for your PR.
Instructions see Pulsar Documentation Label Guide.

@lhotari lhotari added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Aug 24, 2022
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

- fixes issue with stats where timestamps might be inconsistent because of visibility issues
  - fields should be volatile to ensure visibility of updated values in a consistent manner

- in replication, the lastDataMessagePublishedTimestamp field in PersistentTopic might be inconsistent
  unless volatile is used
@lhotari lhotari force-pushed the lh-fix-stats-threadsafety branch from eea55c4 to e231f4e Compare September 28, 2022 09:07
@lhotari lhotari merged commit bde5ac7 into apache:master Sep 28, 2022
@lhotari lhotari added this to the 3.0.0 milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-not-needed Your PR changes do not impact docs Stale type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants