zzyugl / xmemcached

Automatically exported from code.google.com/p/xmemcached
Apache License 2.0
0 stars 0 forks source link

XMemcached network layout exception #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
你好:
我用xmemcached作为kestrel的客户端. 初始化代码如下(scala):

private val kestrelClient = {
    val builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(Config.Kestrel_Servers))
    builder.setCommandFactory(new KestrelCommandFactory)
    builder.setSessionLocator(new RoundRobinMemcachedSessionLocator)
    builder.setConnectionPoolSize(Config.Pool_Size)
    val client = builder.build()
    client.setPrimitiveAsString(true)
    client
  }

在运行单元测试的过程中会有一定几率遇到如下异常(不好重�
��):

[Xmemcached-Reactor-5] [net.rubyeye.xmemcached.impl.MemcachedHandler] [   
MemcachedHandler.java:onExceptionCaught:111:ERROR] - XMemcached network layout 
exception
java.lang.NumberFormatException: For input string: "2.1.1-SNAPSHOT

END
Flushed"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) ~[na:1.6.0_26]
    at java.lang.Integer.parseInt(Integer.java:458) ~[na:1.6.0_26]
    at java.lang.Integer.parseInt(Integer.java:499) ~[na:1.6.0_26]
    at net.rubyeye.xmemcached.command.text.TextGetCommand.decode(TextGetCommand.java:157) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode0(MemcachedDecoder.java:61) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode(MemcachedDecoder.java:51) ~[xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioTCPSession.decode(NioTCPSession.java:288) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioTCPSession.readFromBuffer(NioTCPSession.java:205) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onRead(AbstractNioSession.java:198) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onEvent(AbstractNioSession.java:343) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.SocketChannelController.dispatchReadEvent(SocketChannelController.java:56) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioController.onRead(NioController.java:157) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:294) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:141) [xmemcached-1.3.4.jar:na]

有时也会有另外一种异常:

 [Xmemcached-Reactor-6] [net.rubyeye.xmemcached.impl.MemcachedHandler] [   MemcachedHandler.java:onExceptionCaught:111:ERROR] - XMemcached network layout exception
net.rubyeye.xmemcached.exception.MemcachedDecodeException: Decode error,session 
will be closed,line=Flushed all queues.
    at net.rubyeye.xmemcached.command.Command.decodeError(Command.java:259) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.command.Command.decodeError(Command.java:270) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.command.text.TextGetCommand.decode(TextGetCommand.java:126) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode0(MemcachedDecoder.java:61) ~[xmemcached-1.3.4.jar:na]
    at net.rubyeye.xmemcached.codec.MemcachedDecoder.decode(MemcachedDecoder.java:56) ~[xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioTCPSession.decode(NioTCPSession.java:288) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioTCPSession.readFromBuffer(NioTCPSession.java:205) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onRead(AbstractNioSession.java:198) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.AbstractNioSession.onEvent(AbstractNioSession.java:343) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.SocketChannelController.dispatchReadEvent(SocketChannelController.java:56) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.NioController.onRead(NioController.java:157) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:294) [xmemcached-1.3.4.jar:na]
    at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:141) [xmemcached-1.3.4.jar:na]

我看了下源代码, 
这些异常是不是处理返回数据的时序不对引起的?

Original issue reported on code.google.com by wanti...@gmail.com on 19 Sep 2011 at 2:49

GoogleCodeExporter commented 9 years ago
很奇怪,这个是解析协议的时候出错,返回的不是预期的get��
�议,而是flush协议。

你们测试kestrel和xmc版本是多少?

Original comment by killme2...@gmail.com on 19 Sep 2011 at 2:56

GoogleCodeExporter commented 9 years ago
补充下环境: kestrel 2.1.1-SNAPSHOT, xmemcached 1.3.4, jdk 1.6.0_26-b03, 
ubuntu 10.04

应用环境下xmemcached初始化了2个实例. 
一个作为memcached客户端, 一个作为kestrel客户端, 
用来测试的memcached和kestrel都只有一个, 没做集群.

单独运行每个测试类没问题, 
一起运行整个项目的单元测试的时候就会随机抛出异常.

Original comment by wanti...@gmail.com on 19 Sep 2011 at 3:05

GoogleCodeExporter commented 9 years ago
Thanks,提个不情之请,kestrel的最新版本在我机器上一直编译�
��成功,可以的话,能否讲kestrel-2.1.1-SNAPSHOT这个包作为附件��
�传上来,我好做个测试。测试环境一直用1.2.7这个老版本,��
�版本确实没有做过兼容测试。

Original comment by killme2...@gmail.com on 19 Sep 2011 at 3:14

GoogleCodeExporter commented 9 years ago
我已经通过gmail上传了编译后的版本, 大小15MB, 
googlecode限制是10MB, 不知能不能上传成功. 
我也上传到了我的googlecode里, 你可以从 
http://code.google.com/p/lpotato/downloads/list 下载.

kestrel-2.1.1-SNAPSHOT.zip 是我用的, kestrel-edf1c569.zip 
是github里最新的.

Original comment by wanti...@gmail.com on 19 Sep 2011 at 10:26

GoogleCodeExporter commented 9 years ago
问题找到了,是kestrel的bug,它在返回version协议结果的时候多
了一个空行,跟memcached协议不一致,跟1.2.7这个版本也不一致
。暂时可以先停掉心跳检测来解决这个问题:

memcachedClient.setEnableHeartBeat(false);

Original comment by killme2...@gmail.com on 29 Sep 2011 at 10:26

GoogleCodeExporter commented 9 years ago
github里最新的是没有问题的,你使用的版本是有这个问题。

Original comment by killme2...@gmail.com on 29 Sep 2011 at 10:33

GoogleCodeExporter commented 9 years ago
有无后续反馈?

Original comment by killme2...@gmail.com on 8 Oct 2011 at 1:35

GoogleCodeExporter commented 9 years ago
没有后续反馈我就关闭了。

Original comment by killme2...@gmail.com on 12 Oct 2011 at 9:53