<Codis><JedisPool><DeadLock>
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 Dumptools 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.
Final words
- I have been wondering how to check whether the chained resource is closed. Uh... So I raised a question in stackoverflow.
- Show the amzaing answer:
Try-with-resources close only variable, in your case
Pipeline pipeline. You can read more in docs https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.htmlYou can check it with example:
MyResourceclass:class MyResource implements AutoCloseable { public SubResource getSubResource() {
return new SubResource();
} @Override
public void close() throws Exception {
System.out.println("Resource closed");
}
}SubResourceclass:class SubResource implements AutoCloseable{
@Override
public void close() throws Exception {
System.out.println("SubResource closed");
}
}Mainclass:class Main { public static void main(String[] args) {
try (SubResource s = new MyResource().getSubResource()) {
System.out.println("Before closing");
} catch (Exception e) {
e.printStackTrace();
} System.out.println("After closing");
}
}Execution result:
Before closing
SubResource closed
After closing
<Codis><JedisPool><DeadLock>的更多相关文章
- 简单物联网:外网访问内网路由器下树莓派Flask服务器
最近做一个小东西,大概过程就是想在教室,宿舍控制实验室的一些设备. 已经在树莓上搭了一个轻量的flask服务器,在实验室的路由器下,任何设备都是可以访问的:但是有一些限制条件,比如我想在宿舍控制我种花 ...
- 利用ssh反向代理以及autossh实现从外网连接内网服务器
前言 最近遇到这样一个问题,我在实验室架设了一台服务器,给师弟或者小伙伴练习Linux用,然后平时在实验室这边直接连接是没有问题的,都是内网嘛.但是回到宿舍问题出来了,使用校园网的童鞋还是能连接上,使 ...
- 外网访问内网Docker容器
外网访问内网Docker容器 本地安装了Docker容器,只能在局域网内访问,怎样从外网也能访问本地Docker容器? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Docker容器 ...
- 外网访问内网SpringBoot
外网访问内网SpringBoot 本地安装了SpringBoot,只能在局域网内访问,怎样从外网也能访问本地SpringBoot? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装Java 1 ...
- 外网访问内网Elasticsearch WEB
外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...
- 怎样从外网访问内网Rails
外网访问内网Rails 本地安装了Rails,只能在局域网内访问,怎样从外网也能访问本地Rails? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Rails 默认安装的Rails端口 ...
- 怎样从外网访问内网Memcached数据库
外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装 ...
- 怎样从外网访问内网CouchDB数据库
外网访问内网CouchDB数据库 本地安装了CouchDB数据库,只能在局域网内访问,怎样从外网也能访问本地CouchDB数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Cou ...
- 怎样从外网访问内网DB2数据库
外网访问内网DB2数据库 本地安装了DB2数据库,只能在局域网内访问,怎样从外网也能访问本地DB2数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动DB2数据库 默认安装的DB2 ...
- 怎样从外网访问内网OpenLDAP数据库
外网访问内网OpenLDAP数据库 本地安装了OpenLDAP数据库,只能在局域网内访问,怎样从外网也能访问本地OpenLDAP数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动 ...
随机推荐
- 使用scrapy-crawlSpider 爬取tencent 招聘
Tencent 招聘信息网站 创建项目 scrapy startproject Tencent 创建爬虫 scrapy genspider -t crawl tencent 1. 起始url sta ...
- 小程序授权demo
<button wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo=" ...
- spring boot(十五)spring boot+thymeleaf+jpa增删改查示例
快速上手 配置文件 pom包配置 pom包里面添加jpa和thymeleaf的相关包引用 <dependency> <groupId>org.springframework.b ...
- c# 操作文本文件
计算机在最初只支持ASCII编码,但是后来为了支持其他语言中的字符(比如汉字)以及一些特殊字符(比如€),就引入了Unicode字符集.基于Unicode字符集的编码方式有很多,比如UTF-7.UTF ...
- 移除input框type="number"在部分浏览器的默认上下按钮
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none !impor ...
- atom - Emmet插件使用,代码快速填写
参考转载:http://www.hangge.com/blog/cache/detail_1537.html 用法: 输入:ul>li*6 接着按:tab键 常用语法: 1.后代>: ...
- SQL Server 创建触发器(trigger)
update 触发器: if(OBJECT_ID('trigger_compost_up') is not null) drop trigger trigger_compost_up go creat ...
- Git中的文件上传、修改、撤消修改和删除
1.添加文件.提交文件 1.1在learngit目录下创建一个readme.txt文件,并且输入内容. 1.2添加文件到版本库learngit 1.2.1使用git add 文件告诉Git把文件添加 ...
- 水题系列二:PhoneNumbers
问题描述: Phonenumbers 企业喜欢用容易被记住的电话号码.让电话号码容易被记住的一个办法是将它写成一 个容易记 住的 单词或 者短语 .例如 ,你 需要给 滑铁卢 大学打 电话时 ,可 以 ...
- 2015-09-29 js2
Javasript 六. 条件语句 1. 比较运算符 == .!=.>.>=.<.<= 转大/小写:toUpperCase().toLowerCase() 2. 逻辑运算符(与 ...