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

multi threading bug in XmlUtils.updateMapWithLimit #333

Open
holmeso opened this issue May 24, 2023 · 0 comments
Open

multi threading bug in XmlUtils.updateMapWithLimit #333

holmeso opened this issue May 24, 2023 · 0 comments

Comments

@holmeso
Copy link
Contributor

holmeso commented May 24, 2023

Describe the bug
The XmlUtils.updateMapWithLimit method attempts to cap the number of entries in a map.
However, it is not thread safe, and if multiple threads attempt to insert a new key at the same time, it is possible to get more entries in the map than desired.

This gives non-deterministic results when running multi-threaded apps (eg. qprofiler2)

To Reproduce

  • run qprofiler2 with multiple consumer threads a number of times
  • compare outputs - you will most likely see additional map entries in some instances

Expected behavior
It would be great to be able to run qprofiler2 multiple times with multiple threads and get the same result every time

Additional context
Is there any reason that the map is being kept to a certain size? If it is just the top 100 entries that are required, would it not be a better approach to capture all the entries, and then sort and report on just the top 100? That way you would get the same results every time.

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

No branches or pull requests

1 participant