zyj5340 opened a new issue, #4270:
URL: https://github.com/apache/bookkeeper/issues/4270
**BUG REPORT**
When flushing mem table, the EntryMemTable.flush() method throws an
NullPointerException and it cause the Bookie translate into readonly mode.
***Describe the bug***
While processing FileInfo.readAbsolute() method , it passed the first check
(fc == null) but got NullPointerException while doing fc.read(bb.start), we
think the fc may be closed during two synchronized lock, and that cause the
problem.
ERROR LOG:
```
2024-04-04 04:26:10,349Z [SortedLedgerStorage-0] ERROR
org.apache.bookkeeper.bookie.SortedLedgerStorage - Exception thrown while
flushing skip list cache.
java.lang.NullPointerException: Cannot invoke
"java.nio.channels.FileChannel.read(java.nio.ByteBuffer, long)" because
"this.fc" is null
at
org.apache.bookkeeper.bookie.FileInfo.readAbsolute(FileInfo.java:426)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at org.apache.bookkeeper.bookie.FileInfo.read(FileInfo.java:396)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.LedgerEntryPage.readPage(LedgerEntryPage.java:196)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.IndexPersistenceMgr.updatePage(IndexPersistenceMgr.java:650)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.IndexInMemPageMgr.grabLedgerEntryPage(IndexInMemPageMgr.java:449)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.IndexInMemPageMgr.getLedgerEntryPage(IndexInMemPageMgr.java:414)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.IndexInMemPageMgr.putEntryOffset(IndexInMemPageMgr.java:573)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.LedgerCacheImpl.putEntryOffset(LedgerCacheImpl.java:107)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.InterleavedLedgerStorage.processEntry(InterleavedLedgerStorage.java:539)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.SortedLedgerStorage.process(SortedLedgerStorage.java:288)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.EntryMemTable.flushSnapshot(EntryMemTable.java:255)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
at
org.apache.bookkeeper.bookie.EntryMemTable.flush(EntryMemTable.java:205)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
[root@stage-master-0001 ~]# timed out waiting for input:
auto-logoutgerStorage.java:317)
~[org.apache.bookkeeper-bookkeeper-server-4.14.3]
Connection closed.il.concurrent.Executors$RunnableAdapter.call(Unknown
Source) ~[?:?]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
```
***To Reproduce***
It difficult to reproduce, happen occasionally.
***Additional context***
We want to add a second check if the fc is null in second synchronized, and
if the fc equals null ,we clear the ByteBuffer and return 0. However, we don't
know whether this change will cause another problem or is there a better way to
fix this bug.

--
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]