Renchunbing / xmemcached

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

在网络不稳定的情况下get出来的是空值 #130

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.往memcached服务器set一个值并成功写入
2.开启多个线程不断get
3.反复关闭、开启网卡模拟网络不稳定情况

What is the expected output? What do you see instead?
本应该抛出异常,但是返回空值

What version of the product are you using? On what operating system?
1.3.2,1.3.3

Please provide any additional information below.
在生产环境中使用时发现有些时候get出来空值,但是实际上��
�另外一个xmemcached客户端实例去查询的时候是可以取出来的。

Original issue reported on code.google.com by springda...@gmail.com on 16 Jun 2011 at 3:05

GoogleCodeExporter commented 9 years ago
这种情况没有碰到过。你要有测试代码可以附件发上来,我��
�照你的代码尝试重现看看。其次,想请教下怎么开关网卡,�
��道修改bios设定?

Original comment by killme2...@gmail.com on 16 Jun 2011 at 8:33

GoogleCodeExporter commented 9 years ago
public class Test {

    private static MemcachedClient mc = null;

    public static void main(String[] args) throws Exception {
        XMemcachedClientBuilder builder = new XMemcachedClientBuilder(
                AddrUtil.getAddresses("10.0.30.81:11211 10.0.30.81:11212 10.0.30.81:11213 10.0.30.81:11214 10.0.30.81:11215"));

        builder.setCommandFactory(new BinaryCommandFactory());
        builder.setSessionLocator(new KetamaMemcachedSessionLocator());
        builder.setTranscoder(new SerializingTranscoder());

        mc = builder.build();
        final String key = "store_key_test_1";
        mc.set(key, 0, "store_value_test_1");

        for (int i = 0; i < 10; i++) {
            new Thread(new Runnable() {

                public void run() {
                    while (true) {
                        try {
                            testGet();
                        } catch (Exception e) {
                            sleep();
                        }
                    }
                }

                private void testGet() throws Exception {
                    String fileName = mc.get(key);
                    if (fileName == null) {
                        System.out
                                .println("=================== test get value is nul: "
                                        + key);
                    }
                }

                private void sleep() {
                    try {
                        Thread.sleep(200);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    }
}

windows下:网络连接-》本地连接-》停用-》启用-》停用-》启��
�

Original comment by springda...@gmail.com on 17 Jun 2011 at 5:46

GoogleCodeExporter commented 9 years ago
这个问题的出现是这样,你有多台memcached按照一致性哈希组��
�环,那么当get的那台memcached断开的时候,会查找下一台去get�
��下一台肯定没数据,返回的就是null。

Original comment by killme2...@gmail.com on 18 Jun 2011 at 12:45

GoogleCodeExporter commented 9 years ago
如果你用一台来测试的话,那肯定会跑出异常的。

Original comment by killme2...@gmail.com on 18 Jun 2011 at 12:46

GoogleCodeExporter commented 9 years ago
如果你希望在网络短暂异常的情况下抛出异常而不是查找下��
�个,可以考虑用failure mode.

Original comment by killme2...@gmail.com on 18 Jun 2011 at 12:46

GoogleCodeExporter commented 9 years ago
有没有后续反馈?没有我将关闭这个issue

Original comment by killme2...@gmail.com on 25 Jun 2011 at 12:04

GoogleCodeExporter commented 9 years ago
可以关闭了,谢谢!

Original comment by springda...@gmail.com on 27 Jun 2011 at 12:59

GoogleCodeExporter commented 9 years ago

Original comment by killme2...@gmail.com on 27 Jun 2011 at 1:49

GoogleCodeExporter commented 9 years ago
我就一台机器,内存设置是1500M,每条数据是803个字节,插入
100万条数据,然后轮询其中的数据,得到的都是空

Original comment by zhang...@gmail.com on 8 Sep 2011 at 6:50