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

4.0.11: Add RW locking to better manage concurrency #8999

Merged

Conversation

barchetta
Copy link
Member

Description

Backport of #8997 to 4.0.11

Resolves #8980

The Helidon metrics implementation which uses Micrometer involves several interrelated data structures. Updates to these have always been protected by a lock, but the referenced issue reveals an oversight: read-only operations (which did not participate in locking) could fail in odd ways because the backing data structure for a returned list or set could change.

This PR enhances the locking scheme to use a ReadWriteReentrantLock.

Notable points:

  • Methods which read from the internal data structures now use the read lock.
  • Methods which update the data structures now use the write lock.
  • One method, getOrCreate, starts with a read lock and "promotes" to the write lock as needed. Of course RWRL does not itself support that but the changes to getOrCreate do. See the comments in the revision to the code for details.

Documentation

No impact

* Add RW locking to better manage concurrency

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>

* Address review comments

---------

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
@barchetta barchetta added metrics backport Issues that are merged into a single branch, but missing in either master or previous release 4.x Version 4.x labels Jul 17, 2024
@barchetta barchetta added this to the 4.0.11 milestone Jul 17, 2024
@barchetta barchetta requested a review from tjquinno July 17, 2024 16:46
@barchetta barchetta self-assigned this Jul 17, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 17, 2024
@barchetta barchetta changed the title 4.0.11: Add RW locking to better manage concurrency (#8997) 4.0.11: Add RW locking to better manage concurrency Jul 17, 2024
@barchetta barchetta merged commit aadd6c6 into helidon-io:helidon-4.0.11 Jul 17, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x backport Issues that are merged into a single branch, but missing in either master or previous release metrics OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants