bookkeeper icon indicating copy to clipboard operation
bookkeeper copied to clipboard

Unnecessary contention on "metadataLock" in LedgerHandle while appending from different threads

Open eolivelli opened this issue 1 year ago • 0 comments

BUG REPORT

Describe the bug

Appening to a ledger from different threads leads to high contention on the metadataLock object

https://github.com/apache/bookkeeper/blob/376b9dd12c9443dc9354afb9a613ccb46f84d139/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java#L167

image

I suggest to switch to some form for ReentrantReadWriteLock and distinguish the cases in which there is only readOnly access to the critical sections guarded by the lock, especially on the happy paths (no bookies failures)

To Reproduce

I cannot share my reprorucer but the flame graph is pretty clear.

Expected behavior

Happending to a Ledger from multipple threads should lead to less contention.

Additional context

Using latest BK client 4.17.1

eolivelli avatar Oct 19 '24 10:10 eolivelli