Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freezes in getKeyBytes #1

Closed
kryton opened this issue May 22, 2009 · 5 comments
Closed

freezes in getKeyBytes #1

kryton opened this issue May 22, 2009 · 5 comments

Comments

@kryton
Copy link

kryton commented May 22, 2009

hi.

I'm a newbie to redis, and the client, but thought I'd mention this bug/problem i've got when running the client with 8 threads.

for low traffic it's fine, but it seems to get into a CPU-bound loop when all 8 threads are using the client (HEAD as of 1-2 days ago).

2009-05-21 21:52:00
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0-b16 mixed mode):

"Attach Listener" daemon prio=10 tid=0x0000002ae3826000 nid=0x46f9 runnable [0x0000000000000000..0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"DestroyJavaVM" prio=10 tid=0x0000002ae2774000 nid=0x4663 waiting on condition [0x0000000000000000..0x000000004022ada0]
java.lang.Thread.State: RUNNABLE

"Thread-10" prio=10 tid=0x0000002ae27a4800 nid=0x4682 runnable [0x0000000041b43000..0x0000000041b43d30]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:93)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-9" prio=10 tid=0x0000002ae27a6c00 nid=0x4680 runnable [0x0000000041a42000..0x0000000041a42bb0]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:93)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-8" prio=10 tid=0x0000002ae208e000 nid=0x467e runnable [0x0000000041941000..0x0000000041941c30]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:119)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-7" prio=10 tid=0x0000002ae208d000 nid=0x467d runnable [0x0000000041840000..0x0000000041840ab0]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.set(JRedisSupport.java:260)
at org.jredis.ri.alphazero.JRedisSupport.set(JRedisSupport.java:267)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:135)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-6" prio=10 tid=0x0000002ae20fa400 nid=0x467c runnable [0x000000004173f000..0x000000004173fb30]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:93)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-5" prio=10 tid=0x0000002ae20bc400 nid=0x467b runnable [0x000000004163e000..0x000000004163edb0]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:93)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"Thread-4" prio=10 tid=0x0000002ae2084400 nid=0x4679 runnable [0x000000004153d000..0x000000004153de30]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.lpush(JRedisSupport.java:941)
at org.jredis.ri.alphazero.JRedisSupport.lpush(JRedisSupport.java:948)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:130)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"MaintThread" daemon prio=10 tid=0x0000002adee0e400 nid=0x4678 waiting on condition [0x000000004143c000..0x000000004143ccb0]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at com.danga.MemCached.SockIOPool$MaintThread.run(SockIOPool.java:1492)

"Thread-2" prio=10 tid=0x0000002ae2083c00 nid=0x4676 runnable [0x000000004133b000..0x000000004133bd30]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at org.jredis.ri.alphazero.JRedisSupport.getKeyBytes(JRedisSupport.java:1108)
at org.jredis.ri.alphazero.JRedisSupport.exists(JRedisSupport.java:923)
at com.aol.relegence.feedproc.QTwitterThread.addToRedis(QTwitterThread.java:93)
at com.aol.relegence.feedproc.QTwitterThread.run(QTwitterThread.java:224)

"MySQL Statement Cancellation Timer" daemon prio=10 tid=0x0000002ae20b8c00 nid=0x4673 in Object.wait() [0x000000004123a000..0x000000004123abb0]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000002a9ea4c590> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:485)
at java.util.TimerThread.mainLoop(Timer.java:483)
- locked <0x0000002a9ea4c590> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:462)

"RMI TCP Accept-0" daemon prio=10 tid=0x0000002ae254e000 nid=0x4671 runnable [0x0000000041038000..0x0000000041038ab0]
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
- locked <0x0000002a9ea4cc40> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:34)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:369)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:341)
at java.lang.Thread.run(Thread.java:619)

"RMI TCP Accept-13097" daemon prio=10 tid=0x0000002ae24cd800 nid=0x4670 runnable [0x0000000040f37000..0x0000000040f37b30]
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
- locked <0x0000002a9ea4d298> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:369)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:341)
at java.lang.Thread.run(Thread.java:619)

"RMI TCP Accept-0" daemon prio=10 tid=0x0000002ae24cbc00 nid=0x466f runnable [0x0000000040e36000..0x0000000040e36db0]
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
- locked <0x0000002a9ea4d860> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:369)
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:341)
at java.lang.Thread.run(Thread.java:619)

"Low Memory Detector" daemon prio=10 tid=0x0000002ae2003c00 nid=0x466e runnable [0x0000000000000000..0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x0000002ae2000c00 nid=0x466d waiting on condition [0x0000000000000000..0x0000000040c33540]
java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x0000002adf08e400 nid=0x466c waiting on condition [0x0000000000000000..0x0000000040b325c0]
java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0000002adf08c400 nid=0x466b runnable [0x0000000000000000..0x0000000040a32840]
java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x0000002adf06e400 nid=0x466a in Object.wait() [0x0000000040931000..0x0000000040931c30]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000002a9ea52338> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
- locked <0x0000002a9ea52338> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x0000002adf067000 nid=0x4669 in Object.wait() [0x0000000040830000..0x0000000040830ab0]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000002a9ea12fb0> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x0000002a9ea12fb0> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x0000002adeeb0800 nid=0x4668 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x000000004011cc00 nid=0x4664 runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x000000004011e400 nid=0x4665 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x0000000040120000 nid=0x4666 runnable

"GC task thread#3 (ParallelGC)" prio=10 tid=0x0000000040121800 nid=0x4667 runnable

"VM Periodic Task Thread" prio=10 tid=0x0000002ae2538000 nid=0x4672 waiting on condition

JNI global references: 644

@alphazero
Copy link
Owner

Hi kryton,

The client, as I hope has been sufficiently noted, is not thread safe. n threads requires n clients. Are you using a single instance of JRedisClient for all of the threads?

@kryton
Copy link
Author

kryton commented May 26, 2009

sadly no.
this is how I call it.

public void run() {
JRedis redis = new JRedisClient(this.redisHost, Integer.decode(this.redisPort));
...
}

@alphazero
Copy link
Owner

Alright. In JRedisSupport.java, change:

public static final boolean CacheKeys   = true;

to

public static final boolean CacheKeys   = false;

and let me know if the issue is resolved.

@kryton
Copy link
Author

kryton commented May 27, 2009

looks like that did the trick.
you might want to change the HashMap to ConcurrentHashMap (http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html )

@alphazero
Copy link
Owner

Yep. It was a speed hack to begin with and slipped in to the release. Not sure if everyone would want to pay the memory (and concurrency) cost as it doesn't buy anything for apps that don't have a finite set of keys.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants