dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Kryo serialization fails when the service is both a provider and a consumer(新版本解决了吗?)

Open llx206 opened this issue 8 years ago • 11 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.6.2
  • Operating System version:Red Hat Enterprise Linux Server release 6.6 (Santiago)
  • Java version: 1.8

Step to reproduce this issue

The execution method is as follows:

  1. mvn install all the project.

  2. testissue2116\summary-server run TestSummaryServer to start summary-server service image

  3. testissue2116\dubbo-kryo-server run TestServer to start dubbo-kryo-server service image image image

  4. testissue2116\dubbo-kryo-client run SimpleClient to call dubbo-kryo-server image

Pls. provide [GitHub address] to reproduce this issue. [email protected]:llx206/testKryo.git

Expected Result

What do you expected from the above steps?

Actual Result

What is actually happen? If there is an exception, please attach the exception trace: image

Just put your stack trace here!
I found the problem to be the case when serializing using the kryo protocol. The above exception occurs when the service is both a provider and a consumer. Please help me to see it, thank you very much!

llx206 avatar Aug 03 '18 07:08 llx206

I can reproduce it by following the instructions above. I will look into it.

beiwei30 avatar Aug 06 '18 06:08 beiwei30

建议你还是升级dubbo吧,因为在2.6.1版本中,创建KryoObjectInput这个的Kryo对象会把SerializableClassRegistry里的registrations里采用的是Set集合来缓存类,全都注册进Kryo对象中,所以导致在DefaultClassResolver里的idToRegistration无法和客户端idToRegistration无法对齐。 在2.6.3里采用registrations用了Map<>来缓存类 了。

ZhuoSiChen avatar Sep 04 '18 18:09 ZhuoSiChen

非常感谢,我试一下看看!

在 2018-09-05 02:10:57,"Muxin" [email protected] 写道:

建议你还是升级dubbo吧,因为在2.6.1版本中,创建KryoObjectInput这个的Kryo对象会把SerializableClassRegistry里的registrations里采用的是Set集合来缓存类,全都注册进Kryo对象中,所以导致在DefaultClassResolver里的idToRegistration无法和客户端idToRegistration无法对齐。 在2.6.3里采用registrations用了Map<>来缓存类 了。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

llx206 avatar Sep 05 '18 08:09 llx206

@ZhuoSiChen ,升级到2.6.3后,使用kryo序列化协议,客户端调用还是会出现 image,请帮忙看下吧,多谢!

llx206 avatar Sep 25 '18 09:09 llx206

@llx206 能否给个github 的demo我本地运行下。

ZhuoSiChen avatar Sep 25 '18 09:09 ZhuoSiChen

@ZhuoSiChen ,gitHub地址:https://github.com/llx206/testKryo 操作步骤见最开始处:https://github.com/apache/incubator-dubbo/issues/2179#issue-347287850 大神帮忙看下是什么问题吧,非常感谢!!!

llx206 avatar Sep 25 '18 11:09 llx206

When serializing kryo in my project, the consumer call will also report an error. No provider available for the service com.lewanwuxian.service.AccountService:1.0 from registry 192.168.1.3:2181 on the consumer 192.168.1.29 using the dubbo version 2.6.3. Please check if the providers have been started and registered. My provider and consumer version of dubbo is 2.6.3.

Veryfirefly avatar Oct 12 '18 02:10 Veryfirefly

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.6.2
  • Operating System version:Red Hat Enterprise Linux Server release 6.6 (Santiago)
  • Java version: 1.8

Step to reproduce this issue

The execution method is as follows:

  1. mvn install all the project.
  2. testissue2116\summary-server run TestSummaryServer to start summary-server service image
  3. testissue2116\dubbo-kryo-server run TestServer to start dubbo-kryo-server service image image image
  4. testissue2116\dubbo-kryo-client run SimpleClient to call dubbo-kryo-server image

Pls. provide [GitHub address] to reproduce this issue. [email protected]:llx206/testKryo.git

Expected Result

What do you expected from the above steps?

Actual Result

What is actually happen? If there is an exception, please attach the exception trace: image

Just put your stack trace here!
I found the problem to be the case when serializing using the kryo protocol. The above exception occurs when the service is both a provider and a consumer. Please help me to see it, thank you very much!

llx206 avatar Dec 04 '18 07:12 llx206

Well,It's not Dubbo's bug.It's a bug of how you use it.In your summary-server module,SummaryUser and SummaryPage has been registered as 55, 56.So in your dubbo-kryo-server module,SummaryUser and SummaryPage has been registered as 55, 56.But your dubbo-kryo-server module will regist User and Page as 57,58 when you use Userservice.And your dubbo-kryo-client just regist User and Page as 55,56.So you will get exception 'Encountered unregistered class ID: 57'.You just need regist SummaryUser and SummaryPage in your dubbo-kryo-client moudle. If you use kryo,you must ensure each jvm has same registered classes list.

Bricks-Man avatar Jan 28 '19 06:01 Bricks-Man

Pls focus on https://github.com/apache/incubator-dubbo/issues/2881

@Bricks-Man This is a bug of dubbo. We provide a way for the registry class, so maintaining the relationship of the class id is what we have to do.

carryxyh avatar Jan 28 '19 06:01 carryxyh

Pls focus on #2881

@Bricks-Man This is a bug of dubbo. We provide a way for the registry class, so maintaining the relationship of the class id is what we have to do.

OK.Thx

Bricks-Man avatar Jan 28 '19 07:01 Bricks-Man