Skip to content

Conversation

@kezhuw
Copy link
Member

@kezhuw kezhuw commented Dec 24, 2021

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

Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but can leak memory AFAICT and needs some observability.

// the flush so until this marker is encountered we can skip the force write
if (enableGroupForceWrites) {
forceWriteRequests.put(createForceWriteRequest(req.logFile, 0, 0, null, false, true));
forceWriteMarkerSent = forceWriteRequests.offer(createForceWriteRequest(req.logFile, 0, 0, null, false, true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider logging and incrementing a counter (for monitoring/alerting/troubleshooting) if forceWriteMarkerSent is false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createForceWriteRequest uses pool; if offer failed we need to recycle the request to avoid leak.

@dlg99
Copy link
Contributor

dlg99 commented Jan 3, 2022

also please fix checkstyle error:

[ERROR] /home/runner/work/bookkeeper/bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java:513: Line is longer than 120 characters (found 143). [LineLength]

@kezhuw kezhuw requested a review from dlg99 January 9, 2022 08:04
@kezhuw kezhuw force-pushed the fix-Journal.ForceWriteThread.forceWriteRequests.put-deadlock branch from a050531 to 4365c30 Compare January 9, 2022 08:13
@kezhuw
Copy link
Member Author

kezhuw commented Jan 10, 2022

@dlg99 I have pushed fixup commits to solve your concerns, could you please take another look ?

Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!
let's wait for the CI results + someone else to review.

@dlg99 dlg99 requested review from Vanlightly and eolivelli January 21, 2022 02:11
@dlg99
Copy link
Contributor

dlg99 commented Jan 21, 2022

@eolivelli @Vanlightly FYI

@dlg99 dlg99 added this to the 4.15.0 milestone Mar 10, 2022
@dlg99 dlg99 merged commit 1b1e937 into apache:master Mar 10, 2022
wolfstudy pushed a commit to wolfstudy/bookkeeper that referenced this pull request Aug 2, 2022
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: apache#2948

Reviewers: Andrey Yegorov <None>

This closes apache#2962 from kezhuw/fix-Journal.ForceWriteThread.forceWriteRequests.put-deadlock

(cherry picked from commit 1b1e937)
wolfstudy pushed a commit to wolfstudy/bookkeeper that referenced this pull request Aug 2, 2022
…e request !7)

Cherry pick 4.15 bug changes to repo
1. cherry pick some 4.15.0 changes

- apache#2962
- apache#2836

2. Bump new bookie version to 4.14.4.220419-SNAPSHOT
zymap pushed a commit that referenced this pull request Aug 24, 2022
…equently forceWrite (#3454)

Fix group ForceWrite not take effect with forceWriteMarkerSent in while loop of ForceWriteThread

### Motivation
Bookkeeper 4.15 has performance issue. There are too many journal sync.
Then I found in ForceWriteThread, forceWriteMarkerSent is reset to false for every loop, and this can cause shouldForceWrite=true and trigger journal sync. This new logic is bringed by #2962

### Changes
move forceWriteMarkerSent=false out of while loop.
zymap pushed a commit that referenced this pull request Aug 24, 2022
…equently forceWrite (#3454)

Fix group ForceWrite not take effect with forceWriteMarkerSent in while loop of ForceWriteThread

### Motivation
Bookkeeper 4.15 has performance issue. There are too many journal sync.
Then I found in ForceWriteThread, forceWriteMarkerSent is reset to false for every loop, and this can cause shouldForceWrite=true and trigger journal sync. This new logic is bringed by #2962

### Changes
move forceWriteMarkerSent=false out of while loop.


(cherry picked from commit dcc9a41)
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
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: apache#2948

Reviewers: Andrey Yegorov <None>

This closes apache#2962 from kezhuw/fix-Journal.ForceWriteThread.forceWriteRequests.put-deadlock
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…equently forceWrite (apache#3454)

Fix group ForceWrite not take effect with forceWriteMarkerSent in while loop of ForceWriteThread

### Motivation
Bookkeeper 4.15 has performance issue. There are too many journal sync.
Then I found in ForceWriteThread, forceWriteMarkerSent is reset to false for every loop, and this can cause shouldForceWrite=true and trigger journal sync. This new logic is bringed by apache#2962

### Changes
move forceWriteMarkerSent=false out of while loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants