-
Notifications
You must be signed in to change notification settings - Fork 895
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
Fix Journal without flush #3979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Good catch! Does this bug mean that Bookkeeper hasn't been fsyncing the journal to disk in certain cases? |
Yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a critical bug, and we need to trigger a new release.
+1 |
@@ -421,6 +421,7 @@ private ForceWriteRequest(Handle<ForceWriteRequest> recyclerHandle) { | |||
|
|||
private void recycle() { | |||
logFile = null; | |||
flushed = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of bug is completely avoided by removing object recycling. I understand that object recycling was added a while ago, but I wonder if it is still necessary on JVM 17. It'd be valuable to run benchmarks to verify the underlying assumption that we get better performance by recycling objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be easy to test because you can disable the recycler using Netty Java properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I wonder if we could follow up and add some tests.
We have tests about force() being called (I remember I added them while working on DEFERED_SYNC)
We can add a test to cover the recycle() case in the important place |
@gaozhangmin do we know if it's a regression of a particular BookKeeper version? |
Instead of testing the implementation, perhaps testing the performance a good idea - if missing recycling doesn't cause performance regression, that should be fine. Does BookKeeper have any kind of performance regression coverage now? |
It has, I will test the performance without object recycling. But, I am not sure about the performance impact on low-performance CPUs. |
Co-authored-by: gavingaozhangmin <gavingaozhangmin@didiglobal.com> (cherry picked from commit 50bf016)
Co-authored-by: gavingaozhangmin <gavingaozhangmin@didiglobal.com>
Motivation
In the given code snippet, a ForceWriteRequest object is created with the flushed flag always set to true when calling the createForceWriteRequest method, reused from a recycle pool. Consequently, when the flushFileToDisk method is invoked, it checks the flushed flag and only performs the file flush if it is false. However, since the flushed flag is always true due to the recycling process, the file flush is skipped.
Changes:
To address this issue, the recycle() method should be modified to set the flushed flag to false when recycling a ForceWriteRequest object. This ensures that the flushFileToDisk method will correctly perform the file flush when needed. The updated recycle() method could look like this:
By setting flushed to false during recycling, subsequent reuse of the ForceWriteRequest object will correctly trigger the file flush operation in the flushFileToDisk method when necessary.