首页 > 其他 > 详细

<Codis><JedisPool><DeadLock>

时间:2017-07-18 20:39:05      阅读:406      评论:0      收藏:0      [点我收藏+]

Overview

  • Background: I start a thread [call thread A below]in Spark driver to handle opening files in codis, in which I start six thread [call sub threads below]to handle the files in parallel.

  • What happened:

    • I found the codis openingFilePool never update since a given time.

    • So I looked into the Thread Dump tools of spark, and saw that thread A is always been WAITING. As below:
      技术分享

    •  

      The normal one is as follow:

      技术分享

    • See the difference?
      The thread should be TIMED_WAITING(sleep), not be WAITING(wait for some other threads to awake it)!
    • It seems there is a deadlock?

  • Thread A get a jedis instance from JedisResourcePool to get all opening files.

  • Then, the sub threads handle these opening files and interact with codis in pipeline. [I use try(Pipeline pipeline = CodisPool.getPool().getResource().pipelined())]

Possible causes

  • I am not sure this is because 1) there is no enough instance in JedisPool; or 2) there is a deadlock
    • try (Pipeline pipeline = CodisPool.getPool().getResource().pipelined())
      • I am not sure whether this code will close jedis and pipeline, or it will just close pipeline?

    • JedisResourcePool is not thread-safe?

      • Some says that we should sync when we getResource() from JedisResourcePool. I am not sure.

      • And also I think should I configure the number of Jedis pool. 

 

<Codis><JedisPool><DeadLock>

原文:http://www.cnblogs.com/wttttt/p/7202500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!