dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Two dubbo calls, kryo serialization failed(大神们帮忙看下吧,着急使用)

Open llx206 opened this issue 8 years ago • 5 comments

Environment

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

The two dubbo's SerializationOptimizer registered the bean separately, and the kryo serialization problem occurred. The problem is as follows:

image

llx206 avatar Jul 23 '18 06:07 llx206

hi, could you please provider a demo to reproduce this problem? Thanks a lot.

diecui1202 avatar Jul 23 '18 09:07 diecui1202

@diecui1202 ,The problem is that two dubbo's SerializationOptimizer registers the bean separately, and dubbo uses the map to store the bean class. The key is in numeric order and the value is the path class of the bean. Therefore, the bean cannot be found in the morning. The solution is in each case. The Service's SerializationOptimizer uses the same number of collections. I have tried it, or not. Is there any other solution?

llx206 avatar Jul 24 '18 02:07 llx206

would you mind to attach a simple project on github to reproduce so that we could understand this issue better? @llx206

beiwei30 avatar Jul 25 '18 09:07 beiwei30

@llx206, I did a little bit investigation today, and cannot reproduce it.

I tried to configure two optimizer like this:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <context:property-placeholder location="classpath:benchmark.properties" system-properties-mode="OVERRIDE"/>
    <dubbo:application name="dubbo-kyro-client"/>
    <dubbo:reference id="userService1" check="false"
                     interface="org.apache.dubbo.benchmark.service.UserService"
                     url="dubbo://${server.host}:${server.port}?optimizer=org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl&amp;serialization=kryo"/>
    <dubbo:reference id="userService2" check="false"
                     interface="org.apache.dubbo.benchmark.service.UserService"
                     url="dubbo://${server.host}:${server.port}?optimizer=org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl&amp;serialization=kryo"/>
    <dubbo:consumer client="netty4" filter="-default"/>
</beans>

I can successfully invoke the calls twice with no exception. I put the project at https://github.com/beiwei30/issue2116. Pls. take a look and submit pull request to modify if my test case is incorrect.

beiwei30 avatar Jul 30 '18 11:07 beiwei30

I could reproduce the issue. If the optimizer is not globally known and kept consistent to all participated parties, then the serialization exception gets happen, for example:

service-a (registered with optimizer 1) -> service-b (registered with optimizer 1 + 3) -> service-c (registered with optimizer 3)

In order to solve the issue, optimizer must be registered on service level, which in fact disobeys the current design. One particular serialization optimizer must be bound together with serialization mode onto a protocol definition, for example:

<dubbo:protocol name="dubbo" host="${server.host}" server="netty4" port="${server.port}" serialization="kryo" optimizer="foo.SerializationOptimizerImpl"/>

Because of this, I will simply close this issue and mark it as 'will not fix'. What I suggest to work around this particular situation is to provide the same optimizer implementation among your services, or not to use optimizer at all.

beiwei30 avatar Aug 10 '18 08:08 beiwei30