redis / jedis

Redis Java client
MIT License
11.86k stars 3.87k forks source link

Pipeline exceptions? #127

Closed vivekhub closed 13 years ago

vivekhub commented 13 years ago

I am not sure what I am doing wrong here but a simple pipeline application is bombing rapidly. Here is my code

    Pipeline p = myDb.pipelined();

    Map<String, Integer> buzzwords = item.getTopBuzzwords(-1);
    for (String txtfield : buzzwords.keySet())
    {
        p.zadd(item.getGuid(), buzzwords.get(txtfield), txtfield );
        p.zincrby("SUPERUNION", buzzwords.get(txtfield), txtfield );
    }
    p.sync();

I am seeing the following exceptions on the run...

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:17) at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:15) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21) at PersistArticles.writeArticle(PersistArticles.java:27)

The line 27 is the p.sync() call above. I am not sure if I am doing soemthing wrong or this is a bug. My environment is below.

$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8.3) (6b18-1.8.3-2+squeeze1) OpenJDK Client VM (build 16.0-b13, mixed mode, sharing)

$ uname -a Linux debian 2.6.32-5-686 #1 SMP Tue Mar 8 21:36:00 UTC 2011 i686 GNU/Linux

$ redis-cli -h home-host redis> info redis_version:2.2.4 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:epoll process_id:21225 uptime_in_seconds:29583 uptime_in_days:0 lru_clock:271000 used_cpu_sys:20.12 used_cpu_user:20.71 used_cpu_sys_childrens:2.56 used_cpu_user_childrens:0.23 connected_clients:1 connected_slaves:0 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 used_memory:987552 used_memory_human:964.41K used_memory_rss:24285184 mem_fragmentation_ratio:24.59 use_tcmalloc:0 loading:0 aof_enabled:0 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1302943801 bgrewriteaof_in_progress:0 total_connections_received:586 total_commands_processed:1246539 expired_keys:0 evicted_keys:0 keyspace_hits:1239463 keyspace_misses:164275 hash_max_zipmap_entries:512 hash_max_zipmap_value:64 pubsub_channels:0 pubsub_patterns:0 vm_enabled:0

xetorthio commented 13 years ago

Is there a way for you to isolate somehow the code in a way I can run it and reproduce the error? It might be a bug, but I would like to be able to reproduce it on my end so I can check the details and possible fix it! Thanks for reporting this!!!

On Sat, Apr 16, 2011 at 5:58 AM, vivekhub < reply@reply.github.com>wrote:

I am not sure what I am doing wrong here but a simple pipeline application is bombing rapidly. Here is my code

           Pipeline p = myDb.pipelined();

           Map<String, Integer> buzzwords = item.getTopBuzzwords(-1);
           for (String txtfield : buzzwords.keySet())
           {
                   p.zadd(item.getGuid(), buzzwords.get(txtfield),

txtfield ); p.zincrby("SUPERUNION", buzzwords.get(txtfield), txtfield ); } p.sync();

I am seeing the following exceptions on the run...

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:17) at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:15) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21) at PersistArticles.writeArticle(PersistArticles.java:27)

The line 27 is the p.sync() call above. I am not sure if I am doing soemthing wrong or this is a bug. My environment is below.

$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8.3) (6b18-1.8.3-2+squeeze1) OpenJDK Client VM (build 16.0-b13, mixed mode, sharing)

$ uname -a Linux debian 2.6.32-5-686 #1 SMP Tue Mar 8 21:36:00 UTC 2011 i686 GNU/Linux

$ redis-cli -h home-host redis> info redis_version:2.2.4 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:epoll process_id:21225 uptime_in_seconds:29583 uptime_in_days:0 lru_clock:271000 used_cpu_sys:20.12 used_cpu_user:20.71 used_cpu_sys_childrens:2.56 used_cpu_user_childrens:0.23 connected_clients:1 connected_slaves:0 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 used_memory:987552 used_memory_human:964.41K used_memory_rss:24285184 mem_fragmentation_ratio:24.59 use_tcmalloc:0 loading:0 aof_enabled:0 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1302943801 bgrewriteaof_in_progress:0 total_connections_received:586 total_commands_processed:1246539 expired_keys:0 evicted_keys:0 keyspace_hits:1239463 keyspace_misses:164275 hash_max_zipmap_entries:512 hash_max_zipmap_value:64 pubsub_channels:0 pubsub_patterns:0 vm_enabled:0

Reply to this email directly or view it on GitHub: https://github.com/xetorthio/jedis/issues/127

vivekhub commented 13 years ago

Yep got a sample for you where I managed to simulate the bug.

package bug.redis;

import java.util.HashMap; import redis.clients.jedis.*;

class simulate {

public static void main(String args[])
{
    JedisPool MyPool = new JedisPool("localhost", 6379);

    Jedis myDb = MyPool.getResource();

    Pipeline p = myDb.pipelined();

    HashMap<String, Integer> mydata = new HashMap<String, Integer>();

    mydata.put("test1", 1);
    mydata.put("test2", 1);
    mydata.put("test3", 1);
    mydata.put("test4", 1);
    mydata.put("test5", 1);

    for (String txtfield : mydata.keySet())
    {
        p.zadd("somekey", mydata.get(txtfield), txtfield );
        p.zincrby("SUPERUNION", mydata.get(txtfield), txtfield );
    }
    p.sync();

    MyPool.returnResource(myDb);
}

}

xetorthio commented 13 years ago

thanks a lot! found the bug and pushed the fix to master! :)

vivekhub commented 13 years ago

Fantastic. Tested it myself too. Thanks for the fast turnaround

vivekhub commented 13 years ago

OK I spoke too soon. It now bombs at another location on my main app

java.lang.ClassCastException: java.lang.Long cannot be cast to [B at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:45) at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:43) at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:17) at redis.clients.jedis.BuilderFactory$1.build(BuilderFactory.java:15) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

vivekhub commented 13 years ago

And here

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:35) at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:33) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

xetorthio commented 13 years ago

Which commands are you running within the pipeline? I am probably missing something here.

On Sat, Apr 16, 2011 at 10:33 PM, vivekhub < reply@reply.github.com>wrote:

And here

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:35) at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:33) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

Reply to this email directly or view it on GitHub: https://github.com/xetorthio/jedis/issues/127#comment_1015545

vivekhub commented 13 years ago

Seems like sadd is blowing up now...

package bug.redis;

import java.util.HashMap; import redis.clients.jedis.*;

class simulate_127 {

public static void main(String args[])
{
    JedisPool MyPool = new JedisPool("home-host", 6379);

    Jedis myDb = MyPool.getResource();

    Pipeline p = myDb.pipelined();

    HashMap<String, Integer> mydata = new HashMap<String, Integer>();

    mydata.put("test1", 1);
    mydata.put("test2", 1);
    mydata.put("test3", 1);
    mydata.put("test4", 1);
    mydata.put("test5", 1);

    for (String txtfield : mydata.keySet())
    {
        p.zadd("somekey", mydata.get(txtfield), txtfield );
        p.zincrby("SUPERUNION", mydata.get(txtfield), txtfield );
        p.sadd("setkey", "setstr1");
        p.sadd("setkey", "setstr2");
        p.sadd("setkey", "setstr1");
    }
    p.sync();

    MyPool.returnResource(myDb);
}

}

vivekhub commented 13 years ago

This example crashes like this

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:35) at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:33) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

xetorthio commented 13 years ago

mmm... this is getting weird. the same exact code pass on my machine. are you sure you are using the latest code of the master branch?

please double check and let me know! thanks!

On Sun, Apr 17, 2011 at 12:30 AM, vivekhub < reply@reply.github.com>wrote:

This example crashes like this

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:35) at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:33) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

Reply to this email directly or view it on GitHub: https://github.com/xetorthio/jedis/issues/127#comment_1015755

vivekhub commented 13 years ago

OK I think I messed it up. I was poking around the jedis code and merged your changes to my version instead of master. Sorry about the confusion. Everything works fine when I merged to the master and built a new Jar. You can close this issue now.

On Sun, Apr 17, 2011 at 9:34 AM, xetorthio < reply@reply.github.com>wrote:

mmm... this is getting weird. the same exact code pass on my machine. are you sure you are using the latest code of the master branch?

please double check and let me know! thanks!

On Sun, Apr 17, 2011 at 12:30 AM, vivekhub < reply@reply.github.com>wrote:

This example crashes like this

java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:35) at redis.clients.jedis.BuilderFactory$3.build(BuilderFactory.java:33) at redis.clients.jedis.Response.set(Response.java:15) at redis.clients.jedis.Queable.generateResponse(Queable.java:16) at redis.clients.jedis.Pipeline.sync(Pipeline.java:21)

Reply to this email directly or view it on GitHub: https://github.com/xetorthio/jedis/issues/127#comment_1015755

Reply to this email directly or view it on GitHub: https://github.com/xetorthio/jedis/issues/127#comment_1015801

xetorthio commented 13 years ago

great news! closing now... thanks!!!