SteNicholas opened a new pull request, #1171:
URL: https://github.com/apache/ratis/pull/1171

   ## What changes were proposed in this pull request?
   
   `RaftServerImpl` builds `LogInfoProto` to create `GroupInfoReply` for 
`RaftServer#getGroupInfo` in 
[RATIS-2031](https://issues.apache.org/jira/browse/RATIS-2031), which causes 
`NullPointerException` for null latest snapshot as follows:
   
   ```
   [info] Test 
org.apache.celeborn.service.deploy.master.clustermeta.ha.MasterRatisServerSuiteJ.testIsLeader
 started
   24/10/24 08:16:30,295 ERROR [pool-1-thread-1] HARaftServer: Failed to 
retrieve RaftPeerRole. Setting cached role to UNRECOGNIZED and resetting leader 
info.
   java.io.IOException: java.lang.NullPointerException
       at org.apache.ratis.util.IOUtils.asIOException(IOUtils.java:56)
       at 
org.apache.ratis.server.impl.RaftServerImpl.waitForReply(RaftServerImpl.java:1148)
       at 
org.apache.ratis.server.impl.RaftServerProxy.getGroupInfo(RaftServerProxy.java:607)
       at 
org.apache.celeborn.service.deploy.master.clustermeta.ha.HARaftServer.getGroupInfo(HARaftServer.java:599)
       at 
org.apache.celeborn.service.deploy.master.clustermeta.ha.HARaftServer.updateServerRole(HARaftServer.java:514)
       at 
org.apache.celeborn.service.deploy.master.clustermeta.ha.HARaftServer.isLeader(HARaftServer.java:489)
       at 
org.apache.celeborn.service.deploy.master.clustermeta.ha.MasterRatisServerSuiteJ.testIsLeader(MasterRatisServerSuiteJ.java:47)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
       at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
       at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
       at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
       at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
       at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
       at 
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
       at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
       at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
       at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
       at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
       at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
       at org.junit.runners.Suite.runChild(Suite.java:128)
       at org.junit.runners.Suite.runChild(Suite.java:27)
       at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
       at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
       at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
       at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
       at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
       at com.novocode.junit.JUnitTask.execute(JUnitTask.java:64)
       at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:414)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:750)
   Caused by: java.lang.NullPointerException
       at 
org.apache.ratis.server.impl.RaftServerImpl.getLogInfo(RaftServerImpl.java:665)
       at 
org.apache.ratis.server.impl.RaftServerImpl.getGroupInfo(RaftServerImpl.java:658)
       at 
org.apache.ratis.server.impl.RaftServerProxy.lambda$getGroupInfoAsync$23(RaftServerProxy.java:613)
       at 
java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
       at 
java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
       at 
java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457)
       at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
       at 
java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
       at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
       at 
java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) 
   ```
   
   There is a case for `getSnapshotIndexFromStateMachine` that the index of the 
last entry that has been committed is `RaftLog#INVALID_LOG_INDEX` for null 
latest snapshot in `ServerState`, which causes that the segement log entry of 
the latested committed is null. Therefore, `RaftServerImpl` should set 
committed of `LogInfoProto` without `TermIndex` of `INVALID_LOG_INDEX` latest 
committed index for `SegmentedRaftLog` to avoid `NullPointerException`.
   
   ## What is the link to the Apache JIRA
   
   See [RATIS-2179](https://issues.apache.org/jira/browse/RATIS-2179).
   
   ## How was this patch tested?
   
   `MasterRatisServerSuiteJ#testIsLeader` of Celeborn.


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