Fix Journal.ForceWriteThread.forceWriteRequests.put deadlock
authorKezhu Wang <kezhuw@gmail.com>
Thu, 10 Mar 2022 00:09:25 +0000 (08:09 +0800)
committerGitHub <noreply@github.com>
Thu, 10 Mar 2022 00:09:25 +0000 (16:09 -0800)
commit1b1e9370f39e386d660ceee11660d7ee87fbb460
treebcb40696a143cf626dda55f9e33729e7f44a8d1d
parent3edbc98824bbdf574d97510aec783d5b9355548e
Fix Journal.ForceWriteThread.forceWriteRequests.put deadlock

Descriptions of the changes in this PR:

### Motivation
`Journal.ForceWriteThread` could deadlock as it is the sole consumer of `Journal.forceWriteRequests` while it send group marker blocking using `BlockingQueue.put`.

This PR try to fix this.

### Changes
* Add testing code to deadlock `Journal.ForceWriteThread` on `forceWriteRequests.put`.
* Send force write group marker non-blocking to avoid deadlock `ForceWriteThread`.

Master Issue: #2948

Reviewers: Andrey Yegorov <None>

This closes #2962 from kezhuw/fix-Journal.ForceWriteThread.forceWriteRequests.put-deadlock
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookKeeperServerStats.java
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/stats/JournalStats.java
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieWriteToJournalTest.java