[Jedis] ERR wrong number of arguments for 'mget'
看别人写的代码是件比较痛苦的事情,更加痛苦的是别人的代码出错还要负责调试好。
关于如何迅速定位问题和调试代码,我的一点感受是:逐行认真查看错误信息,在这些信息中找自己熟悉的内容(包括文件名、方法名等),不熟悉的内容先跳过。针对这些熟悉的内容,回溯相应的代码所在行,定位错误原因。
切忌囫囵吞枣的看了一通,其实什么有效信息也没有获得,也几乎不可能就这样定位到问题。
举例:
1、定位问题
在使用jedis监听和订阅消息时报以下错误。经逐行查看错误信息,定位到斜体的三行:分析错误原因是mget调用出错,且错误代码在OnlineFriend文件的112/257行。
redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'mget' command
at redis.clients.jedis.Protocol.processError(Protocol.java:59) at redis.clients.jedis.Protocol.process(Protocol.java:66)
at redis.clients.jedis.Protocol.read(Protocol.java:131)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:188)
at redis.clients.jedis.Jedis.mget(Jedis.java:873)
at com.caffinc.OnlineFriend$MsgListener.onMessage(OnlineFriend.java:112)
at com.caffinc.OnlineFriend.main(OnlineFriend.java:257)
出错代码如下:List topRoles = jedis.srandmember(top_set_key, 10);
List topLevels = jedis.mget(topRoles.toArray(new String[0]));
2、检查问题
根据以上代码,分析可能原因是jedis.mget(key)方法没有获取到key值,即key为空。
直接在redis-cli中运行> srandmember top_set_key,发现top_set_key集合为空,并由此导致mget方法参数缺失。
3、问题处理
导入相应数据到redis top_set_key集合,重新运行代码后一切正常。
总结下,有两点收获:一是调试代码要逐行认真看错误信息,不可囫囵吞枣;二是具体到技术点,mget如果参数为空,会导致ERR wrong number of arguments for 'mget' 错误。
[Jedis] ERR wrong number of arguments for 'mget'的更多相关文章
- redis cluster 的ERR max number of clients reached 问题排查
早上发现微服务连不上redis cluster了,看来下日志如下 [root@win-jrh378d7scu 7005]# bin/redis-cli -c -h 15.31.213.183 -p 7 ...
- wrong number of arguments,java方法反射时数组参数的坑
java方法中只有一个参数是数组,反射的时候我们不能想当然的传歌数组进去,传数组进去的时候表示多个参数. 两个数组不是一个意思啊. 我们应该把数组转为objet,这样才表示一个参数. import j ...
- Error Code: 1318. Incorrect number of arguments for PROCEDURE company.new_procedure; expected 2, got
1.错误叙述性说明 20:27:34 call new_procedure(20150112) Error Code: 1318. Incorrect number of arguments for ...
- Error Code: 1318. Incorrect number of arguments for PROCEDURE student.new_procedure; expected 0, got
1.错误描述 13:58:20 call new_procedure('2000','zhangsan') Error Code: 1318. Incorrect number of argument ...
- Variable number of arguments (Varargs)
A parameter of a function (normally the last one) may be marked with vararg modifier: fun <T> ...
- hbase ERROR: wrong number of arguments (3 for 4)
hbase(main):036:0> get 'ddl', 'example', 'info:age'COLUMN ...
- 反射报错java.lang.IllegalArgumentException: wrong number of arguments
class Person{ private String name ; private String sex ; public Person(){ System.out.println("c ...
- [nginx]invalid number of arguments
invalid number of arguments nginx出现以下的错误,基本上错误的原因就是少了后面的分号导致. invalid number of arguments
- Lua 变长参数(variable number of arguments)
lua变长参数 function add ( ... ) for i, v in ipairs{...} do print(i, ' ', v) end end add(1, 2, 'sdf') lu ...
随机推荐
- mysql排序的中文首字母排序和自定义排序
select * FROM organ_new where city_code = 'SZ0755' and organ_type = 'H' and state = '1' ORDER BY FIE ...
- mysql 全文搜索(转载http://blog.csdn.net/manbujingxin/article/details/6656992)
前提:mysql只支持英文内容的全文索引,所以只考虑英文的全文搜索.假定数据表名为post,有三列:id.title.content.id是自增长序号,title是varchar,content是te ...
- [CodeForces - 614A] A - Link/Cut Tree
A - Link/Cut Tree Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, ...
- maven聚合工程使用如何debug
maven聚合工程在正常情况下,使用debug时会出错,因为没有源码,就不会显示代码和断点行数条. 进行如下操作: 默认情况下source下只有默认的default文件夹,点击remove进行删除(这 ...
- Oracle 12c启动时PDBs的自动打开
Pluggable Database(PDB)为Oracle 12c中的一个重要的新特性, 但启动12c实例时并不会自动打开PDB数据库,这样,在启动实例后必须手动打开PDBs. 1. 实例启动后,手 ...
- js 时间戳转特定格式的日期
var Tools = {}; Tools.formatDate = function (fmt,timestamp) { if(timestamp){ var date = new Date(par ...
- URL to load resources from the classpath in Java
In Java, you can load all kinds of resources using the same API but with different URL protocols: fi ...
- python 关闭垃圾回收
import gc gc.disable() http://blog.csdn.net/aixiaohei/article/details/6446869
- nyoj 0325 zb的生日(dp)
nyoj 0325 zb的生日 zb的生日 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 今天是阴历七月初五,acm队员zb的生日.zb正在和C小加.never在武汉集 ...
- shell 文件条件判断
按照文件类型进行判断 '-b 文件' 判断该文件是否存在,并且是否为块设备文件(是块设备文件为真) '-c 文件' 判断该文件是否存在,并且是否为字符设备文件(是字符设备文件为真) '-d 文件' 判 ...