-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-27632 Refactor WAL.Reader implementation so we can better suppo… #5055
Conversation
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
The PR is big, but most files are just boiler plate changes as we changed the class name for reading a WAL file. The most important things are:
Thanks. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
OK, good. All green! |
/** | ||
* Get the current reading position. | ||
*/ | ||
long getPosition() throws IOException; |
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.
I noticed that WALTailingReader
and WALStreamReader
these two interfaces both declare this method, totally same. Then the specific implementation classes ProtobufWALStreamReader
and ProtobufWALTailingReader
do not implement it, but implements it through the parent abstract class AbstractProtobufWALReader
.
So I think maybe you can delete it in these two interfaces.
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 upper layer can only get a WALTailingReader or WALStreamReader, they can not see the AbstractProtobufWALReader... So if we remove this method from these two interfaces, the upper layer classes can not use this method any more...
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.
Got it. Thank you.
I've read through the entire patch as best I can, and haven't found anything wrong.
…rt WAL splitting and replication
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@@ -5669,12 +5676,17 @@ private long replayRecoveredEdits(final Path edits, Map<byte[], Long> maxSeqIdIn | |||
coprocessorHost.postReplayWALs(this.getRegionInfo(), edits); | |||
} | |||
} catch (EOFException eof) { | |||
Path p = WALSplitUtil.moveAsideBadEditsFile(walFS, edits); |
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.
Have we never ignored EOF before?
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 the old ProtobufLogReader implementation, usually we will not throw EOFException out, so in the past this is not a big problem. But anyway, we could open a issue to backport this change to branch-2.x.
/** | ||
* When outside clients need to consume persisted WALs, they rely on a provided Reader. | ||
*/ | ||
interface Reader extends Closeable { |
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.
Nice!
} catch (EOFException e) { | ||
throw new WALHeaderEOFException("EOF while reading PB WAL magic", e); | ||
} | ||
if (!Arrays.equals(PB_WAL_MAGIC, magic)) { |
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.
Is it our first time checking PB_WAL_MAGIC? I found out we just skip its bytes length before.
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, in the old implementation we just skip these bytes. I think it is OK here as the magic is short so we will not add too much pressure?
return header; | ||
} | ||
|
||
private void initDecryptor(WALProtos.WALHeader header) throws IOException { |
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.
Great! we merge SecureProtobufLogReader and ProtobufLogReader here.
// is a partial trailer | ||
return true; | ||
} | ||
if (r != 0) { |
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.
Is the length of the current HBase implementation WALTrailer all 0?
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, there is nothing in the trailer yet. There is a UT to confirm this, see this line
Line 98 in bc8b13e
assertEquals(0, WALTrailer.newBuilder().build().getSerializedSize()); |
} | ||
} | ||
|
||
private Reader getReader(String wal) throws IOException { | ||
private WALStreamReader getReader(String wal) throws IOException { |
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.
Why didn't we use TailingReader in this replication scenario?
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 WAL replay. Although it is part of the sync replication implementation, it is not for 'replicating' data, it does not need to tail the WAL file, just read the file once and replay the edits.
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
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…rt WAL splitting and replication (#5055) Signed-off-by: GeorryHuang <[email protected]> (cherry picked from commit e48c448) Conflicts: hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplaySyncReplicationWALCallable.java hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestProtobufLog.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogTestHelper.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCombinedAsyncWriter.java hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestSyncReplicationActive.java hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestSyncReplicationWALProvider.java hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALReaderOnSecureWAL.java
…rt WAL splitting and replication