Open laniakea1990 opened 1 year ago
Cannot invoke "String.toLowerCase()" because the return value of "java.lang.Throwable.getMessage()" is null
2023-04-21 22:08:00.705 WARN 10165 --- [1.117.233.35-19] c.n.eureka.util.batcher.TaskExecutors : Discovery WorkerThread error
java.lang.NullPointerException: Cannot invoke "String.toLowerCase()" because the return value of "java.lang.Throwable.getMessage()" is null at com.netflix.eureka.cluster.ReplicationTaskProcessor.maybeReadTimeOut(ReplicationTaskProcessor.java:196) at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:95) at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:190) at java.base/java.lang.Thread.run(Thread.java:833)
Description:
An issue has been discovered where an uncommon but occasional exception can occur in the maybeReadTimeOut() method in ReplicationTaskProcessor.java. This can lead to the batchingDispatcher thread pool in the PeerEurekaNode class being exhausted, resulting in registration inconsistencies between nodes in the Eureka cluster.
To reproduce the issue, a 3-node Eureka cluster (node1, node2, node3) was deployed on a Kubernetes container cloud with relevant peer node configurations. In certain exceptional scenarios, the maybeReadTimeOut() method in ReplicationTaskProcessor.java can throw a NullPointerException in its String message = e.getMessage().toLowerCase() line. This exception is caught in the process() method, which passes it to the BatchWorkerRunnable inner class. Each occurrence of the exception causes one less working thread in the batchingDispatcher. The batchingDispatcher's initial working thread count is 20 (read from config.getMaxThreadsForPeerReplication()). When all 20 working threads on Eureka node node1 are exhausted due to the NullPointerException, this causes the Eureka node to fail to execute synchronization registration instance information and other tasks.
some essential code list below:
Environment:
Kubernetes container cloud Eureka version: 1.10.7 Java version: 1.8.0_202