-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27354 EOF thrown by WALEntryStream causes replication blocking #4756
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
base: master
Are you sure you want to change the base?
Conversation
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -255,15 +255,21 @@ private void dequeueCurrentLog() throws IOException { | |||
* Returns whether the file is opened for writing. | |||
*/ | |||
private boolean readNextEntryAndRecordReaderPosition() throws IOException { | |||
long prePos = reader.getPosition(); |
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 think this is a nice improvement that we can return earlier when there is no data can be read. But I do not get the point that why here if we try to read more data can lead to a problem? We could still hit EOFException when the remaining data is not enough for a whole entry?
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.
Thanks for reviewing.
I haven't found out yet that we read an incomplete entry. EOFException is thrown by org.apache.hadoop.fs.FSDataInputStream#seek
.
After reading the uncommitted data, we will reopen FSDataInputStream
and seek back. If the position where seek back is the sync length, it may cause EOF. As the 3 copies of the hdfs block being written are inconsistent, even if we can read the data from a specific position in one copy, it may not be read in the other one.
It's not a big problem if it just throws EOF as we'll retry. The big problem is that if we have read some entries into the WALEntryBatch
and increased the totalBufferUsed
, and the totalBufferUsed
is not subtracted after throwing EOF, all peers will eventually block completely.
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's not a big problem if it just throws EOF as we'll retry. The big problem is that if we have read some entries into the WALEntryBatch and increased the totalBufferUsed, and the totalBufferUsed is not subtracted after throwing EOF, all peers will eventually block completely.
One of our customers seems to be consistently reaching this EOF problem, per below exception trace.
WARN org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader: Encountered a malformed edit, seeking back to last good position in file, from 31912404 to 31912265 java.io.EOFException: EOF while reading 106 WAL KVs; started reading at 31912338 and read up to 31912404 at org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader.readNext(ProtobufLogReader.java:397) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:98) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:86) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.readNextEntryAndRecordReaderPosition(WALEntryStream.java:262) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.tryAdvanceEntry(WALEntryStream.java:176) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.hasNext(WALEntryStream.java:101)
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.
Then I do not think the fix here is enough? We should decrease the totalBufferUsed when calling resetReader?
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.
Checking the code, we have a special logic in ReplicationSourceWALReader for dealing with EOFException. Please see ReplicationSourceWALReader.handleEofException.
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.
Thanks @wchevreuil for reviewing and sharing the case. This looks like it reads an incomplete entry?
Then I do not think the fix here is enough?
As @Apache9 said, this fix may not enough, it may not cover that reading incomplete entry caused by like RS down. I'm digging deeper into the root cause.
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.
@wchevreuil for the above stacktrace you mentioned, which version the cluster is running on?
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.
FYI @apurtell
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.
One of our customers seems to be consistently reaching this EOF problem, per below exception trace.
WARN org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader: Encountered a malformed edit, seeking back to last good position in file, from 31912404 to 31912265 java.io.EOFException: EOF while reading 106 WAL KVs; started reading at 31912338 and read up to 31912404 at org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader.readNext(ProtobufLogReader.java:397) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:98) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:86) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.readNextEntryAndRecordReaderPosition(WALEntryStream.java:262) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.tryAdvanceEntry(WALEntryStream.java:176) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.hasNext(WALEntryStream.java:101)
@wchevreuil, this problem seems not throw EOFException in WALEntryStream.readNextEntryAndRecordReaderPosition
, it may be another problem?
@@ -255,15 +255,21 @@ private void dequeueCurrentLog() throws IOException { | |||
* Returns whether the file is opened for writing. | |||
*/ | |||
private boolean readNextEntryAndRecordReaderPosition() throws IOException { | |||
long prePos = reader.getPosition(); |
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's not a big problem if it just throws EOF as we'll retry. The big problem is that if we have read some entries into the WALEntryBatch and increased the totalBufferUsed, and the totalBufferUsed is not subtracted after throwing EOF, all peers will eventually block completely.
One of our customers seems to be consistently reaching this EOF problem, per below exception trace.
WARN org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader: Encountered a malformed edit, seeking back to last good position in file, from 31912404 to 31912265 java.io.EOFException: EOF while reading 106 WAL KVs; started reading at 31912338 and read up to 31912404 at org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader.readNext(ProtobufLogReader.java:397) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:98) at org.apache.hadoop.hbase.regionserver.wal.ReaderBase.next(ReaderBase.java:86) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.readNextEntryAndRecordReaderPosition(WALEntryStream.java:262) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.tryAdvanceEntry(WALEntryStream.java:176) at org.apache.hadoop.hbase.replication.regionserver.WALEntryStream.hasNext(WALEntryStream.java:101)
@ddupg curious if you have any workaround for this on live cluster? do you restart regionservers? |
Any updates here @ddupg ? If not, I think we could open a new issue to land the improvement here first, no harm. Thanks. |
@virajjasani Previously we had to restart regionservers, after this patch, the problem still exist, but the frequency has slowed to an acceptable level. |
In WALEntryStream#readNextEntryAndRecordReaderPosition, it is possible that we read uncommitted data. If we read beyond the committed file length, then reopen inputStream and seek back.
In our use, we found that the position where seek back may be exactly the length of the file being written, which may cause EOF. The thrown EOF is finally caught by ReplicationSourceWALReader.run, but totalBufferUsed is not cleanup up.
After a long run, all peers will go slow and eventually block completely.