This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch branch-4.14
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/branch-4.14 by this push:
     new 7460cf5ad2 [branch-4.14] Fix the problem that the abnormal file causes 
the bookie GC fail (#3611)
7460cf5ad2 is described below

commit 7460cf5ad25c7c6e7b3b77045c7992044e3db2f8
Author: wangjun <[email protected]>
AuthorDate: Mon Nov 21 17:01:36 2022 +0800

    [branch-4.14] Fix the problem that the abnormal file causes the bookie GC 
fail (#3611)
    
    Descriptions of the changes in this PR:
    
    Motivation
    When bookie GC encounters an entryLog file with disordered data, a 
IllegalArgumentException are not caught, resulting in the death of the GC 
thread and the end of the GC process.
    This problem is encountered again in the next GC, resulting in the 
subsequent entrylog being unable to GC.
    The problem described in this 
issue(https://github.com/apache/bookkeeper/issues/3604) will cause the entryLog 
file to be disordered, and will cause the IllegalArgumentException when parsing 
the entrylog file.
    
    Master Issue:
    https://github.com/apache/bookkeeper/issues/3607 : Describes the problem to 
be solved by this pr.
    https://github.com/apache/bookkeeper/issues/3604 : Describes the phenomenon 
and causes of disordered entrylog files.
---
 .../main/java/org/apache/bookkeeper/bookie/EntryLogger.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
index f8d457ca1e..adc9307a8d 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
@@ -991,6 +991,11 @@ public class EntryLogger {
                 long offset = pos;
                 pos += 4;
                 int entrySize = headerBuffer.readInt();
+                if (entrySize <= 0) { // hitting padding
+                    pos++;
+                    headerBuffer.clear();
+                    continue;
+                }
                 long ledgerId = headerBuffer.readLong();
                 headerBuffer.clear();
 
@@ -1001,11 +1006,6 @@ public class EntryLogger {
                 }
                 // read the entry
                 data.clear();
-                if (entrySize <= 0) {
-                    LOG.warn("bad read for ledger entry from entryLog {}@{} 
(entry size {})",
-                            entryLogId, pos, entrySize);
-                    return;
-                }
                 data.capacity(entrySize);
                 int rc = readFromLogChannel(entryLogId, bc, data, pos);
                 if (rc != entrySize) {

Reply via email to