1.3.2nacos<--->2.2.3nacos双向同步时,暂停其中的一个task,重启jvm会抛出空指针 异常 #337 #338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
环境:有A(nacos1.3.2)和B(nacos2.2.3)两个集群,为A集群创建namespace名为aNamesparce,为B集群创建namespace为bNamespace,在nacos-sync中创建两个task,分别是A->B和B->A双向同步,serviceName均设置为ALL用以同步所有。
问题1:如果将B->A的同步任务暂停(暂停A->B的也可以),然后重启jvm,QuerySyncTaskTimer类会扫描到DELETE的task,发送DeleteTaskEvent,在listener中监听并调用NacosSyncToNacosServiceImpl#delete方法,方法中会调用popNamingService方法获取namingService(从serviceClient Map中获取),因为这个serviceClient Map的存储在该版本中只有在sync的listener中才会put,这个DELTE task就永远获取不到namingService,会直接抛出NPE。


问题2:如果暂停成功,则老的实例不会被注销掉。如下图所示:


这个serviceClient去重有4个namingService,任务10有两个分别是各个服务引用的NacosNamingService@2b056461和ALL引用的NacosNamingService@7c95663,任务11也有两个,分别是各个服务引用的NacosNamingService@75beac01和ALL引用的NacosNamingService@4dea1449,如果任务名为ALL的话,会获取到单独的ALL namingService,服务注册不是通过ALL注册的,所以注销会失败,服务不会下线,修复完成之后一切正常。
问题3:如果注册的服务没有元数据,ServiceInfo接口返回的json中,Instance的metadata属性被指定为null,导致NPE;
