AnonHxy opened a new pull request, #4425:
URL: https://github.com/apache/bookkeeper/pull/4425

   Descriptions of the changes in this PR:
   
   ### Motivation
   
   When the `ReadEntryProcessor` runs slow, the `TimedRunnable` will print the 
warn log like below:
   ```
   Runnable xx:xx took too long xx micros to execute.
   ```
   
https://github.com/apache/bookkeeper/blob/fd2c7c6f632deb0130b9c8fc506a6b66ac02b341/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java#L197-L208
   
   However we found that NPE happened in this log:
   ```
   WARN  
[BookieReadThreadPool-OrderedExecutor-1-0:OrderedExecutor$TimedRunnable@206] - 
Runnable 
[!!!org.apache.bookkeeper.proto.ReadEntryProcessor@1dd094f3=>java.lang.NullPointerException:Cannot
 invoke "org.apache.bookkeeper.proto.BookieProtocol$ReadRequest.getLedgerId()" 
because "this.request" is null!!!]:class 
org.apache.bookkeeper.proto.ReadEntryProcessor took too long 1125904 micros to 
execute.
   ```
   
   The root cause is that the  `ReadEntryProcessor` will be recycled after 
calling `run` method,  which meas we shouldn't call any method of the 
`ReadEntryProcessor` after call `ReadEntryProcessor#run()`.   So line206 call  
`toString()` method  of `runnable`(`ReadEntryProcessor`) will cause NPE or any 
other wrong  message.
   
   
   ### Changes
   
   Save runnable  string name and class when create `TimedRunnable` and 
`TimedCallable`
   


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

Reply via email to