<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 安装并启动 ...
随机推荐
- android------eclipse运行错误提示 Failed to load D:\Android\sdk\build-tools\26.0.0-preview\lib\dx.jar
更新了SDK后,在ecplise上运行项目时出现了一个问题. 一运行就提示这个错误:Your project contains error(s), please fix them before run ...
- 04 爬虫数据存储之Mongodb
MongoDB 认识MongoDB MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个介于关系数据库和非关系数据 ...
- springboot activiti 配置项详解
asyncExecutorEnabled属性设置设置true后将代替那些老的Job executorspring.activiti.async-executor-enabled=false sprin ...
- flex对象.show()的时候display变成block
在css中设置display: none;的对象会出现这种情况. 在JavaScript中用.hide()隐藏的对象不会出现.
- Utils--字符串的帮助类
Utils--字符串的帮助类 一个关于字符串过滤的工具类,主要时针对username和password的过滤 package com.bw.yun.utils; import java.securit ...
- iOS 时间校准解决方案
背景 在 iOS 开发中,凡是用到系统时间的,都要考虑一个问题:对时.有些业务是无需对时,或可以以用户时间为准的,比如动画用到的时间.一些日程类应用等.但电商相关的业务大都不能直接使用设备上的时间,而 ...
- GCC 命令行详解 -L 指定库的路径 -l 指定需连接的库名 zhuan
1.gcc包含的c/c++编译器gcc,cc,c++,g++,gcc和cc是一样的,c++和g++是一样的,(没有看太明白前面这半句是什么意思:))一般c程序就用gcc编译,c++程序就用g++编译 ...
- linux系统管理 启停命令
mac下Linux的登录命名 'ssh -l root 192.168.10.109' password: xxxx 退出登录 >> logout shutdown命令 要使用这个命令 ...
- shell 基本概述
SHELL的概念 SHELL是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序, 用户可以用shell来启动,挂起,停止甚至是编写一些程序. Shell还是 ...
- The difference between ppp and ndis