dubbo "offline" command causes "Notify service xxx with urls 0"

qlzsbp2j  于 8个月前  发布在  其他
关注(0)|答案(4)|浏览(171)
  • I have searched the issues of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 3.1.1
  • Operating System version: linux
  • Java version:1.8

Steps to reproduce this issue

  1. we use "offline" to shutdown dubbo app gracefully. when we offline more than two instances, it is possible for consumers to get the phenomenon.

reviewing the dubbo source code, we find that when offlining a instance it will remove services in "MetadataInfo" but
the field "revision of MetadataInfo" won't change in time. if a consumer requests metadatainfo from the offlining instance, it will response the metadatainfo without services.

Pls. provide [GitHub address] to reproduce this issue.

Expected Behavior

Actual Behavior

If there is an exception, please attach the exception trace:

  1. Just put your stack trace here!
wf82jlnq

wf82jlnq1#

Can you provide abnormal stack information? I also use offline commands for offline traffic and have not encountered this issue before. Version 3.1.0

mctunoxg

mctunoxg2#

It is not an exception. There's no stack information. But I use Arthas to debug the consumer, and then find a cue as the following image. We can see that the filed "services" is a empty array.

The empty "services" cause the "urls 0" problem certainly.

pgpifvop

pgpifvop3#

Please try update to 3.2.1.

qq24tv8q

qq24tv8q4#

I'm afraid it is not repaired in 3.2.1.
Step:
first: when we offline an instance, it unexports all the interfaces . what MetadataInfo to do is just remove serviceKey from the array services and mark the "revision" should be updated. but the field "revision" is not really changed. If a request for metadataInfo comes now, it will response the empty services. I think the method getRevision() of MetadataInfo should check whether the filed "updated" is true or not. if true, the method should not return a value. because of the revision can't represent the MetadataInfo now.

  1. public synchronized void removeService(URL url) {
  2. if (url == null) {
  3. return;
  4. }
  5. this.services.remove(url.getProtocolServiceKey());
  6. if (exportedServiceURLs != null) {
  7. removeURL(exportedServiceURLs, url);
  8. }
  9. updated = true;
  10. }
  11. public void unregister(URL url) {
  12. metadataInfo.removeService(url);
  13. }
展开查看全部

相关问题