Aerospike Java 异步库似乎卡住了
Aerospike Java Async library seems stuck
我正在使用 aeropike 异步客户端执行 udf。客户端已初始化为:-
try {
asyncClientPolicy.maxThreads = 40;
asyncClientPolicy.asyncMaxCommands = 20;
asyncClientPolicy.maxSocketIdle = 13;
asyncClientPolicy.asyncMaxCommandAction = MaxCommandAction.BLOCK;
asyncClientPolicy.asyncSelectorThreads = 7;
asyncClientPolicy.asyncTaskThreadPool = Executors.newFixedThreadPool(20, new ThreadFactory() {
public final Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
}
});
}
所以我有 20 个线程来处理回调。过了一会儿,我看到我的程序没有任何进展,表明 deadlock/starvation。 Jstack 给我以下结果:-
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000064048f338> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:374)
at com.aerospike.client.async.AsyncCluster$BlockBufferQueue.getByteBuffer(AsyncCluster.java:114)
at com.aerospike.client.async.AsyncCluster.getByteBuffer(AsyncCluster.java:68)
at com.aerospike.client.async.AsyncCommand.execute(AsyncCommand.java:59)
at com.aerospike.client.async.AsyncClient.execute(AsyncClient.java:949)
at main.java.labs.RuleEngineAerospikeConnection.updatePositiveSegmentsUDF(RuleEngineAerospikeConnection.java:217)
at main.java.labs.Segment$ProductChecker.onSuccess(Segment.java:346)
at com.aerospike.client.async.AsyncRead.onSuccess(AsyncRead.java:149)
at com.aerospike.client.async.AsyncCommand.finish(AsyncCommand.java:293)
at com.aerospike.client.async.AsyncSingleCommand.read(AsyncSingleCommand.java:59)
at com.aerospike.client.async.AsyncCommand.run(AsyncCommand.java:261)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我正好有 20 个线程在等待 execute
命令。我是否在设置上做错了什么,因为我希望客户端 return,即使我的 UDF 中有任何异常,如果出现无限循环会怎样?它会导致这种行为吗?
如果不查看源代码,很难说出是什么导致了死锁。您的 AsyncClientPolicy 看起来足够了。
无论如何,旧的 AsyncClient class 自 version 4 以来已经过时了。 AerospikeClient class 现在包括新的异步方法,其执行速度必须比旧的 AsyncClient 快。新的异步方法还支持 Netty 事件循环,并且始终 运行 在非阻塞模式下。
我正在使用 aeropike 异步客户端执行 udf。客户端已初始化为:-
try {
asyncClientPolicy.maxThreads = 40;
asyncClientPolicy.asyncMaxCommands = 20;
asyncClientPolicy.maxSocketIdle = 13;
asyncClientPolicy.asyncMaxCommandAction = MaxCommandAction.BLOCK;
asyncClientPolicy.asyncSelectorThreads = 7;
asyncClientPolicy.asyncTaskThreadPool = Executors.newFixedThreadPool(20, new ThreadFactory() {
public final Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
}
});
}
所以我有 20 个线程来处理回调。过了一会儿,我看到我的程序没有任何进展,表明 deadlock/starvation。 Jstack 给我以下结果:-
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000064048f338> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:374)
at com.aerospike.client.async.AsyncCluster$BlockBufferQueue.getByteBuffer(AsyncCluster.java:114)
at com.aerospike.client.async.AsyncCluster.getByteBuffer(AsyncCluster.java:68)
at com.aerospike.client.async.AsyncCommand.execute(AsyncCommand.java:59)
at com.aerospike.client.async.AsyncClient.execute(AsyncClient.java:949)
at main.java.labs.RuleEngineAerospikeConnection.updatePositiveSegmentsUDF(RuleEngineAerospikeConnection.java:217)
at main.java.labs.Segment$ProductChecker.onSuccess(Segment.java:346)
at com.aerospike.client.async.AsyncRead.onSuccess(AsyncRead.java:149)
at com.aerospike.client.async.AsyncCommand.finish(AsyncCommand.java:293)
at com.aerospike.client.async.AsyncSingleCommand.read(AsyncSingleCommand.java:59)
at com.aerospike.client.async.AsyncCommand.run(AsyncCommand.java:261)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我正好有 20 个线程在等待 execute
命令。我是否在设置上做错了什么,因为我希望客户端 return,即使我的 UDF 中有任何异常,如果出现无限循环会怎样?它会导致这种行为吗?
如果不查看源代码,很难说出是什么导致了死锁。您的 AsyncClientPolicy 看起来足够了。
无论如何,旧的 AsyncClient class 自 version 4 以来已经过时了。 AerospikeClient class 现在包括新的异步方法,其执行速度必须比旧的 AsyncClient 快。新的异步方法还支持 Netty 事件循环,并且始终 运行 在非阻塞模式下。