-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-24625 AsyncFSWAL.getLogFileSizeIfBeingWritten does not return the expected synced file length(addendum) #2055
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8c5de7
HBASE-24625 addnum
comnetwork 212166e
Merge remote-tracking branch 'upstream/master' into hbase24625addnumm…
comnetwork 91eac7c
HBASE-24625 addnum
comnetwork 42f368f
Merge remote-tracking branch 'upstream/master' into hbase24625addnumm…
comnetwork efb161f
add finalSyncedLength to support getSyncedLength after AsyncProtobufW…
comnetwork 1772b5f
Merge remote-tracking branch 'upstream/master' into hbase24625addnumm…
comnetwork 255b26b
add finalSyncedLength to support getSyncedLength after AsyncProtobufW…
comnetwork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we really need to make it volatile? IIRC, it will be initialized in the init call and we will always call it when constructing a new ProtobufLogWriter. Make it volatile may cause developer confusing...
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.
The
outputwould be set to null inAsyncProtobufLogWriter.closeand would be used ingetSyncedLengthmethod, and seems there is no explicit constraint on which thread could invokeAsyncProtobufLogWriter.close, so here usevolatileThere 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.
We will also use output in other methods where we do not test whether it is null, only test it in this method seems a bit confusing...
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.
Yes, you are right, I ignored other
writemethods also not test whetheroutputis null. The problem here is it is meaningless to callAsyncProtobufLogWriter.getSyncedLengthafterAsyncProtobufLogWriter.close, which indeed occured when #1970 is applied to branch-2 previously caused by problematic state synchronization.If we do not test whether output is null, we can just leave some comments here.
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.
Oh, then this is another problem? I think it is allowed to call getSyncedLength after closing? We should not throw IllegalStateException...
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes ,the problem description is :
https://issues.apache.org/jira/browse/HBASE-24625?focusedCommentId=17152610&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17152610
In my opinion,
AsyncProtobufLogWriter.getSyncedLengthis used forWALFileLengthProvider.getLogFileSizeIfBeingWrittenand is just meaningful when the WAL file is current writing, onceAsyncProtobufLogWriteris closed(BTW,AsyncProtobufLogWriter.outputis null), upperlayer code seems no need to call this method, and if upperlayer code still call this method after closed, it may indicates some synchronization error or other.If we allow to call
getSyncedLengthafter closing, we should save thesyncedLengthwhenAsyncProtobufLogWriter.close, or elsegetSyncedLengthwill throwNullPointExceptionor just return 0, both are unexpected and may cause upperlayer code error.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.
In practise, as we will call getSyncedLength in another thread, it is possible that we call getSyncedLength on a closed writer. Maybe we could introduce another field to save the final length of the file, and in getSyncedLength, we check whether we have this field set, if so we just return the value of this field, otherwise we will go to get output. WDYT?
Uh oh!
There was an error while loading. Please reload this page.
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.
@Apache9 , Yes, I agree with you, and would modify PR following your suggestion.
BTW, for now,
AsyncProtobufLogWriter.getSyncedLengthis only used when the WAL file is writing.AsyncProtobufLogWriter.getSyncedLengthfor closed wrter may be used for future use.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.
@Apache9 , I modify PR to introduce
finalSyncedLengthto save the syncedLength whenAsyncProtobufLogWriter.close.But in
getSyncedLengthmethod, I check whether output is null instead of checking whetherfinalSyncedLengthis set, because I think the statement "this.output = null;" inAsyncProtobufLogWriter.closeis a good sync point, if output is null, thenfinalSyncedLengthmust set, so we can returnfinalSyncedLength, else we returnoutput.getSyncedLength.If we use
finalSyncedLengthas a sync point, it is hard to decide whether theoutputis null or not.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.
@Apache9 , please have a review, thanks.