hangc0276 commented on code in PR #3437:
URL: https://github.com/apache/bookkeeper/pull/3437#discussion_r1169469405
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java:
##########
@@ -884,22 +885,31 @@ public long scanJournal(long journalId, long journalPos,
JournalScanner scanner)
}
boolean isPaddingRecord = false;
if (len < 0) {
- if (len == PADDING_MASK && journalVersion >=
JournalChannel.V5) {
- // skip padding bytes
- lenBuff.clear();
- fullRead(recLog, lenBuff);
- if (lenBuff.remaining() != 0) {
- break;
+ try {
+ if (len == PADDING_MASK && journalVersion >=
JournalChannel.V5) {
+ // skip padding bytes
+ lenBuff.clear();
+ fullRead(recLog, lenBuff);
+ if (lenBuff.remaining() != 0) {
+ break;
+ }
+ lenBuff.flip();
+ len = lenBuff.getInt();
+ if (len == 0) {
+ continue;
+ }
+ isPaddingRecord = true;
+ } else {
+ LOG.error("Invalid record found with negative
length: {}", len);
+ throw new IOException("Invalid record found with
negative length " + len);
}
- lenBuff.flip();
- len = lenBuff.getInt();
- if (len == 0) {
- continue;
+ } catch (IOException e) {
+ if (skipInvalidRecord) {
Review Comment:
If we just skip one record and continue to read the next one, I'm afraid it
will cause ledger data errors. Because when one journal file is broken, the
rest of the data will be organized in the wrong way and we can't parse it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]