You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/09/26 03:38:09 UTC

[GitHub] [shardingsphere] caqhy opened a new issue, #21183: Throw NPE when processing events.

caqhy opened a new issue, #21183:
URL: https://github.com/apache/shardingsphere/issues/21183

   ## Bug Report
   
   ### Use Etcd in cluster mode
   1.The node that starts first can not see the logical database created by the node that starts later
   2.Throw NPE when processing events
   ```[ERROR] 2022-08-30 12:37:15.186 [grpc-default-executor-0] c.g.common.eventbus.EventBus.default - Exception thrown by subscriber method renew(org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.datasource.DataSourceChangedEvent) on subscriber org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator@5438c17a when dispatching event: org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.datasource.DataSourceChangedEvent@63f88bd4
   java.lang.NullPointerException: null
   	at org.apache.shardingsphere.mode.manager.ContextManager.getStaleResourceHeldRules(ContextManager.java:324)
   	at org.apache.shardingsphere.mode.manager.ContextManager.alterDataSourceConfiguration(ContextManager.java:288)
   	at org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator.renew(ClusterContextManagerCoordinator.java:162)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:87)
   	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:144)
   	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:72)
   	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)
   	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:67)
   	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:108)
   	at com.google.common.eventbus.EventBus.post(EventBus.java:212)
   	at org.apache.shardingsphere.infra.util.eventbus.EventBusContext.post(EventBusContext.java:51)
   	at java.base/java.util.Optional.ifPresent(Optional.java:183)
   	at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory.lambda$watch$0(GovernanceWatcherFactory.java:59)
   	at org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository.lambda$watch$2(EtcdRepository.java:140)
   	at io.etcd.jetcd.Watch$1.onNext(Watch.java:105)
   	at io.etcd.jetcd.WatchImpl$WatcherImpl.onNext(WatchImpl.java:248)
   	at io.etcd.jetcd.WatchImpl$WatcherImpl.onNext(WatchImpl.java:99)
   	at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:436)
   	at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
   	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658)
   	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643)
   	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
   	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   
   
   ### Which version of ShardingSphere did you use?
   latest master
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   
   ### Expected behavior
   The node that starts first can see the logical database created by the node that starts later.
   
   ### Actual behavior
   The node that starts first can not see the logical database created by the node that starts later.
   
   ### Reason analyze (If you can)
   Etcd:
   Because the parent path: `/metadata/databaseName` event is missing, subsequent event processing throws NPE.
   Where errors occur:
   ![1664162929517](https://user-images.githubusercontent.com/75082574/192188313-36b1ae85-48ff-4c2e-a8da-3ff701b414f0.png)
   
   Zookeeper:
   When persistent data is like '/metadata/databaseName/versions/0/dataSources', Zookeeper server will preferentially build parent path:`/metadata/databaseName` and broadcast this event:`/metadata/databaseName` to client. During event:`/metadata/databaseName` processing, the following code logic will be executed:
   ![image](https://user-images.githubusercontent.com/75082574/192188179-25627407-47fa-478b-bf39-d3c01c8b7e82.png)
   Therefore, subsequent events are handled normally.
   
   ### Solution
   Etcd Client preferentially persists parent path.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 closed issue #21183: Throw NPE when processing events.

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 closed issue #21183: Throw NPE when processing events.
URL: https://github.com/apache/shardingsphere/issues/21183


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org