sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.59k stars 1.15k forks source link

the problem of thread number #308

Closed hanzhihua closed 5 years ago

hanzhihua commented 5 years ago

Your question

我使用jraft时候,日志大小一般是10k左右,偶尔会受到下面异常: [JRaft-Closure-Executor-26] ERROR com.alipay.sofa.jraft.util.LogThreadPoolExecutor - Uncaught exception in pool: JRAFT_CLOSURE_EXECUTOR, com.alipay.sofa.jraft.util.MetricThreadPoolExecutor@5d7dd05a[Running, pool size = 200, active threads = 198, queued tasks = 0, completed tasks = 127323]. java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@5f781a26 rejected from com.alipay.sofa.jraft.util.MetricThreadPoolExecutor@5d7dd05a[Running, pool size = 200, active threads = 198, queued tasks = 0, completed tasks = 127323] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830) ~[?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379) ~[?:1.8.0_161] at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[?:1.8.0_161] at com.alipay.sofa.jraft.util.Utils.runInThread(Utils.java:153) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.onError(Replicator.java:969) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.util.ThreadId.unlock(ThreadId.java:115) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.sendEntries(Replicator.java:1453) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.continueSending(Replicator.java:898) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.lambda$waitMoreEntries$8(Replicator.java:1423) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.storage.impl.LogManagerImpl.runOnNewLog(LogManagerImpl.java:1112) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.storage.impl.LogManagerImpl.lambda$wakeupAllWaiter$4(LogManagerImpl.java:410) ~[raftexample.jar:1.7.21] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_161] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]

我已经把线程数据从100给成了200,还有这样的问题,请问一下,是不是使用方式不对,谢谢

再咨询一下,10k左右大小的日志,tps一般是多少,我测试数据是500左右,sync=true,使用了segmentstore方式

Environment

jdk1.8 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux raft 1.2.6 3台集群

sofastack-bot[bot] commented 5 years ago

Hi @hanzhihua, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Your question When I use jraft, the log size is usually around 10k, and occasionally I get the following exception: [JRaft-Closure-Executor-26] ERROR com.alipay.sofa.jraft.util.LogThreadPoolExecutor - Uncaught exception in pool: JRAFT_CLOSURE_EXECUTOR, com.alipay.sofa.jraft.util.MetricThreadPoolExecutor@5d7dd05a[Running, pool size = 200, active threads = 198, queued tasks = 0, completed tasks = 127323]. java.util.concurrent.RejectedExecutionException: Task java. util.concurrent.FutureTask@5f781a26 rejected from com.alipay.sofa.jraft.util.MetricThreadPoolExecutor@5d7dd05a[Running, pool size = 200, active threads = 198, queued tasks = 0, completed tasks = 127323] at java.util. concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830) ~[?:1.8.0_161] at java. util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379) ~[?:1.8.0_161] at java.util.concurrent.AbstractEx ecutorService.submit(AbstractExecutorService.java:112) ~[?:1.8.0_161] at com.alipay.sofa.jraft.util.Utils.runInThread(Utils.java:153) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.onError(Replicator.java:969) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.util.ThreadId.unlock(ThreadId.java:115 ) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.sendEntries(Replicator.java:1453) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft .core.Replicator.continueSending(Replicator.java:898) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.core.Replicator.lambda$waitMoreEntries$8(Replicator.java:1423) ~[raftexample .jar:1.7.21] at com.alipay.sofa.jraft.storage.impl.LogManagerImpl.runOnNewLog(LogManagerImpl.java:1112) ~[raftexample.jar:1.7.21] at com.alipay.sofa.jraft.storage .impl.LogManagerImpl.lambda$wakeupAllWaiter$4(LogManagerImpl.java:410) ~[raftexample.jar:1.7.21] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8 .0_161 ] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161] At java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161] I have Send thread data from 100 to 200, there is such a problem, may I ask, is not the way to use it, thank you for consulting, about 10k size log, tps is generally how much, my test data is about 500, sync= True, using the segmentstore method### Environment jdk1.8 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 deb8u3 (2015-08-04) x86_64 GNU/Linux raft 1.2.6 3 clusters

fengjiachun commented 5 years ago

你的信息太少,基本上无法判断,一些基本的排查工作需要你自己来,比如 gc 状况等,机器负载,线程上下文切换情况等等

segment log 已经建议过你暂时不要使用,不知道你为啥这么执着呢 :)

这个文档第10节,有一些问题排查手段建议先看一下 https://www.sofastack.tech/projects/sofa-jraft/jraft-user-guide/

你上个 issue 没更多问题我就 close 了

fengjiachun commented 5 years ago

如果你要做 benchmark , 可以参考这个文档 https://www.sofastack.tech/projects/sofa-jraft/benchmark-performance/

源码就在 jraft 工程里,你可以调整参数来控制 value 大小

fengjiachun commented 5 years ago

这个 issue 先关闭了,如果问题还是无法解决,请提供更多信息并开一个 新的 issue 吧