<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 安装并启动 ...
随机推荐
- Confluence 6 指派空间权限概念
如果你是一个空间的管理员,你可以对空间的使用权限进行控制.你可以为独立用户或者Confluence Groups的权限进行权限的指派/收回. Confluence 管理员可以将用户分配到用户组中,这样 ...
- apiCloud 调微信支付,调支付宝支付
data里面的参数信息,需要从后台接口中调取,点击查看微信支付详情,https://docs.apicloud.com/Client-API/Open-SDK/wxPay 首先,需要在config.x ...
- 完整的Django入门指南学习笔记3
前言 在本节课中,我们将深入理解两个基本概念: URLs 和 Forms.在这个过程中,我们还将学习其它很多概念,如创建可重用模板和安装第三方库.同时我们还将编写大量单元测试. 如果你是从这个系列教程 ...
- python 发送邮件+多人+附件 最好用!!!
#!python3#codin=utf-8import yagmail yag = yagmail.SMTP(user='2679813@qq.com', password='mwlgdmwv4rss ...
- 『TensorFlow』SSD源码学习_其五:TFR数据读取&数据预处理
Fork版本项目地址:SSD 一.TFR数据读取 创建slim.dataset.Dataset对象 在train_ssd_network.py获取数据操作如下,首先需要slim.dataset.Dat ...
- 使用virustotal VT 查询情报——感觉远远没有微步、思科好用,10万条数据查出来5万条都有postives >0的记录,尼玛!!!
1399 git clone https://github.com/VirusTotal/c-vtapi.git 1400 cd c-vtapi/ 1402 sudo apt-get install ...
- ffmpeg+libmp3lame库源码安装教程(CentOS)
lame--libmp3lame的安装包,支持MP3编码:yasm--NASM的重写,用于编译ffmpeg. 1.下载 ffmpeg下载链接:http://ffmpeg.org/download.ht ...
- 正则表达式test()和exec()、 search() 和 replace()用法实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 加号变空格问题 url参数 post get 请求发送
问题:加号后台接收变空格问题 结论: 1.任何get拼接的请求 参数key value 需要编码后在拼接 2.get请求避免做数据提交,用post提交.jq,axios的post提交默认编码了不会有问 ...
- axios API速查表
原来jq自带ajax方法,但是近期项目用vue,在vue项目中发送ajax请求原来用vue resource,现在更推荐使用axios,因为axios和vue更配! GET 请求 // Make a ...