Re: ERR syntax error while getting the a member with highest score from a sorted set

617 views
Skip to first unread message

Onur GUNDURU

unread,
Mar 1, 2013, 5:43:15 AM3/1/13
to jedis...@googlegroups.com
It seems it has nothing to do with pipelining,

whenever i execute the following line (with or without pipelining) i get a "ERR syntax error"

Set<Tuple> set = jedis.zrangeWithScores("mykey", -1, -1);

every jedis.z* method (returning a tuple) gives the same error. Is this a JEDIS bug? I can execute these lines with success on REDIS-CLI

Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: ERR syntax error
    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.getBinaryMultiBulkReply(Connection.java:199)
    at redis.clients.jedis.Connection.getMultiBulkReply(Connection.java:192)
    at redis.clients.jedis.Jedis.getTupledSet(Jedis.java:2290)
    at redis.clients.jedis.Jedis.zrangeWithScores(Jedis.java:1572)
    at com.oy.kaarun.kpm.crawler.test.RedisTest.main(RedisTest.java:44)


On Thursday, 28 February 2013 23:12:47 UTC+2, Onur GUNDURU wrote:
Hello,

Having difficulties with getting the a member with highest score from a sorted set and then removing this record from REDIS. Basically i'm trying to grab the highest scored player from the list. Following code produces the error below (marked with red line). It would be a great if someone could point me in the right direction.

Thanks a lot,

Best!

Onur

CODE

        Jedis jedis = pool.getResource();
        // create a pipeline
        Pipeline p = jedis.pipelined();
        // get player with top score
        Response<Set<Tuple>> player = p.zrangeWithScores(setKey, 0, -1);
        // now delete them from the redis frontier
        jedis.zremrangeByRank(setKey, 0, -1);
        // execute
        p.sync();
        // return pool
        pool.returnResource(jedis);

EXCEPTION
Exception in thread "Thread-4" redis.clients.jedis.exceptions.JedisDataException: ERR syntax error
    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.zremrangeByRank(Jedis.java:2378)
...

Sam Hendley

unread,
Mar 1, 2013, 2:59:28 PM3/1/13
to jedis...@googlegroups.com
We have unit tests to cover that call so I'd be suprised if it was just producing a bad syntax. 

Make absolutely sure you are not using a client from more than one thread. The clients can not be used from multiple threads at the same time. Thats the most common cause of errrors we see.

If that doesn't fix it please connect to your server with redis-cli and run "monitor" while trying this again so we can see exactly what the malformed string is sending?  

Sam


--
You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Onur GUNDURU

unread,
Mar 6, 2013, 7:25:32 AM3/6/13
to jedis...@googlegroups.com
I dont think there's a concurrency issue here, because my test is a simple main class with nothing else in it. Yet i isolated the code below,

looking with the monitor i saw a weird "w\xc4\xb1thscores" output which maybe because of the locale operations (i.e. uppercase, lowercase) without defining locale. In such cases the solution is the using Locale.ENGLISH.

// use the english locale to avoid the infamous turkish locale bug
String upperName = permissionName.toUpperCase(Locale.ENGLISH);

http://mattryall.net/blog/2009/02/the-infamous-turkish-locale-bug

        Jedis jedis = pool.getResource();
        Set<Tuple> res = jedis.zrangeWithScores("mykey".getBytes(), -1, -1);
        pool.returnResource(jedis);

redis 127.0.0.1:6379> monitor
OK
1362569152.260200 [0 10.0.0.33:61204] "ZRANGE" "mykey" "-1" "-1" "w\xc4\xb1thscores"

Best!

Onur
Reply all
Reply to author
Forward
0 new messages