redis client 2.0.0 pipeline 的list的rpop bug

描写叙述:

redis client 2.0.0 pipeline 的list的rpop 存在严重bug,rpop list的时候,假设list已经为空的时候,rpop出来的Response依旧不为null,导致吊response.get()方法抛异常

代码:

@Test
	public void testRedisPipeline(){
	    Jedis jedis = null;
	    try{
	        jedis = new Jedis("127.0.0.1",6379);
	        Pipeline pipelined = jedis.pipelined();
	        for(int i=200;i<10000;i++){
	            pipelined.lpush("aa", "val"+i);
	        }
	        pipelined.sync();

	    }catch(Exception e){
	        e.printStackTrace();
	    }finally{
	        if(jedis!=null){
	            jedis.disconnect();
	        }
	    }
	}
	
<span style="white-space:pre">	</span>//这种方法会造成redis qps无限上升
	@Test
	public void testRedisPipelinePop(){
	    Jedis jedis = null;
	    try{
	        List<Response<String>> result = new ArrayList<Response<String>>();
	        jedis = new Jedis("127.0.0.1",6379);
	        Pipeline pipelined = jedis.pipelined();
	        for(int i=0;i<10;i++){
	            //System.out.println(i);
	            Response<String> rpop = pipelined.rpop("aa");
	            //System.out.println(rpop);
	            result.add(rpop);
	        }
	        pipelined.sync();
	        //Response<Long> r = pipelined.bitcount("aa");
	        for (Response<String> response : result) {
                System.out.println(response.get());//异常
            }

	    }catch(Exception e){
	        e.printStackTrace();
	    }finally{
	        if(jedis!=null){
	            jedis.disconnect();
	        }
	    }
	}

解决方法:

使用redis-cli 2.1.0以上版本号

时间: 2024-08-24 19:50:56

redis client 2.0.0 pipeline 的list的rpop bug的相关文章

./redis-trib.rb 报错:/usr/local/rvm/gems/ruby-2.4.2/gems/redis-4.0.1/lib/redis/client.rb:119:in `call&#39;: ERR Slot 0 is already busy (Redis::CommandError)

错误提示是 slot插槽被占用了(这是 搭建集群前时,以前redis的旧数据和配置信息没有清理干净.) 解决方案是 用redis-cli 登录到每个节点执行  flushall  和 cluster reset  就可以了. 然后重新执行群集脚本命令: ./redis-trib.rb create --replicas 1 192.168.*.*:7001 192.168.*.*:7002 192.168.*.*:7003 192.168.*.*:7004 192.168.*.*:7005  1

Redis 3.0.0 正式版出炉,高性能 K/V 服务

Redis 3.0.0 正式版最终到来了,与 RC6 版本号比較.该版本号改进包含: * 修复了无磁盘的复制问题 (Oran Agra) * 在角色变化后对 BLPOP 复制进行測试 (Salvatore Sanfilippo) * prepareClientToWrite() 错误处理方法的改进 (Salvatore Sanfilippo) * 移除 dict.c 中不再使用的函数(Salvatore Sanfilippo Redis 3.0 版本号与 2.8 版本号比較,主要新特性包含例如以

高屋建瓴 cocos2d-x-3.0架构设计 Cocos2d (v.3.0) rendering pipeline roadmap(原文)

Cocos2d (v.3.0) rendering pipeline roadmap Why (the vision) The way currently Cocos2d does rendering is good but it is beginning to feel somehow antiquate and moreover it doesn't actually leverage modern multi core CPUs so popular nowadays on most mo

Could not connect to Redis at 192.168.0.129:6379: Connection refused

在虚拟机上(CentOS 6.7)本机连接自己的redis [[email protected] bin]# ./redis-cli -h 192.168.0.129 -p 6379 Could not connect to Redis at 192.168.0.129:6379: Connection refused Could not connect to Redis at 192.168.0.129:6379: Connection refused not connected> 查看配置文

elk(Elasticsearch 2.0.0, Logstash 2.0.0, Kibana4.2.0) redis centos6.6安装与配置

本次安装的相关环境:Centos_x64_6.6  redis2.8.23  Elasticsearch 2.0.0, Logstash 2.0.0,  Kibana4.2.0 软件下载地址: redis: http://redis.io/download Elasticsearch: wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticse

Redis 服务端配置——Could not connect to Redis at 127.0.0.1:6379: Connection refused

[[email protected] 桌面]# redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected> exit [[email protected] 桌面]# redis-server /etc/redis.conf [[email prote

Redis发布了集群版3.0.0 beta

Redis不是比较成熟的Memcache或者Mysql的替代品,是对于大型互联网类应用在架构上很好的补充.现在有越来越多的应用也在纷纷基于Redis做架构的改造. Redis已经发布集群版3.0.0beta,相信在不久的将来就会出稳定版本. redis cluster 集群规范 安装 Redis集群版3.0.0beta版的功能介绍如下: This is the first beta of Redis 3.0.0. Redis 3.0 features support for Redis Clus

Redis连接时报错:Could not connect to Redis at 127.0.0.1:6379: Connection refused

Could not connect to Redis at 127.0.0.1:6379: Connection refused [[email protected] bin]# redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused [[email protected] /]# redis-server /etc/redis.conf [[email protected] /]# redis-cli

iptables不小心把127.0.0.1封了,导致redis连不上

写了个脚本扫描apache日志,自动把恶意攻击者的ip交给iptables给封掉 谁知道一不小心把127.0.0.1也给封了... 直接导致redis无法链接. redis-server服务正常启动,端口也开着,日志全都正常,就是redis客户端(redis-cli和python api)连不上,报错timeout. 一查链接状态,发现客户端是SYN_SENT,也就是“客户端发出了连接请求,等待服务端响应”. iptabls把127.0.0.1给解封后,就恢复正常了.