Skip to content

Add warning log if ReentrantShortLock is held too long #6186

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

Closed
wants to merge 6 commits into from

Conversation

JihwanByun
Copy link

Motivation:

ReentrantShortLock is designed for short-lived locking in non-blocking threads. However, because blocking calls inside this class are allowed via BlockHound.allowBlockingCallsInside(), long lock hold times are not detected by BlockHound. This can potentially hide contention issues or misuses.

This change introduces a mechanism to detect when a lock is held longer than expected and logs a warning to help developers identify such cases.

Modifications:

  • Added duration tracking in ReentrantShortLock using ThreadLocal.
  • Logs a warning if the lock is held longer than the configured threshold.
  • Threshold is configurable via the JVM option: -Dcom.linecorp.armeria.reentrantShortLockWarnThresholdMillis=<millis>.
  • Default threshold is set to 50ms.
  • Added flag integration using FlagsProvider, Flags, and DefaultFlagsProvider.

Result:

@CLAassistant
Copy link

CLAassistant commented Mar 31, 2025

CLA assistant check
All committers have signed the CLA.

@JihwanByun JihwanByun closed this Mar 31, 2025
@JihwanByun JihwanByun reopened this Mar 31, 2025
@JihwanByun JihwanByun closed this Mar 31, 2025
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.

Report a ReentrantShortLock that holds a lock for a long time.
2 participants