死锁

  项目遇到的死锁问题

项目假死

问题描述:
  在linux服务器中,springboot项目运行一段时间后,ps -ef|grep java发现项目进程在,但是打开日志,请求项目接口,发现服务器没有反应,好像死了一样。什么原因呢?
解决:
  问题出现后,通过 jstack 进程id 发现,出现了死锁问题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
JNI global references: 296
Found one Java-level deadlock:
=============================
"http-nio-8889-exec-34":
waiting to lock monitor 0x00007fe2c45001d8 (object 0x0000000086bef5e8, a com.hfy.service.impl.SessionServiceImpl),
which is held by "SockJS-1"
"SockJS-1":
waiting to lock monitor 0x00007fe2d424ec98 (object 0x0000000086bef5c8, a com.hfy.service.impl.TokenServiceImpl),
which is held by "SockJS-2"
"SockJS-2":
waiting to lock monitor 0x00007fe2c45001d8 (object 0x0000000086bef5e8, a com.hfy.service.impl.SessionServiceImpl),
which is held by "SockJS-1"
Java stack information for the threads listed above:
===================================================
"http-nio-8889-exec-34":
at com.hfy.service.impl.SessionServiceImpl.keepAlive(SessionServiceImpl.java:114)
- waiting to lock <0x0000000086bef5e8> (a com.hfy.service.impl.SessionServiceImpl)
at com.hfy.PmWebSocketHandler.handleTextMessage(PmWebSocketHandler.java:85)
- locked <0x00000000d8ca01c8> (a org.springframework.web.socket.adapter.standard.StandardWebSocketSession)
............
"SockJS-1":
at com.hfy.service.impl.TokenServiceImpl.deleteToken(TokenServiceImpl.java:49)
- waiting to lock <0x0000000086bef5c8> (a com.hfy.service.impl.TokenServiceImpl)
............
at com.hfy.service.impl.SessionServiceImpl.sessionTimeout(SessionServiceImpl.java:96)
- locked <0x0000000086bef5e8> (a com.hfy.service.impl.SessionServiceImpl)
at com.hfy.service.ScheduleTask.sessionTimeout(ScheduleTask.java:75)
.......
"SockJS-2":
at com.hfy.service.impl.SessionServiceImpl.deleteSession(SessionServiceImpl.java:47)
- waiting to lock <0x0000000086bef5e8> (a com.hfy.service.impl.SessionServiceImpl)
............
at com.hfy.service.impl.TokenServiceImpl.tokenTimeout(TokenServiceImpl.java:80)
- locked <0x0000000086bef5c8> (a com.hfy.service.impl.TokenServiceImpl)
at com.hfy.service.ScheduleTask.tokenTimeout(ScheduleTask.java:69)
.......
Found 1 deadlock.

可以很清楚的看到:
  “SockJS-2”:
  TokenServiceImpl.java:80执行tokenTimeout()的时候,获得了锁<0x0000000086bef5c8>,方法执行到了SessionServiceImpl.java:47,执行deleteSession时,等待锁<0x0000000086bef5e8>
  “SockJS-1”:
  SessionServiceImpl.java:96执行sessionTimeout()的时候,获得了锁<0x0000000086bef5e8>,方法执行到了TokenServiceImpl.java:49,执行deleteToken时,等待锁<0x0000000086bef5c8>
  典型的死锁,知道问题所在,解决去了。。。。。。

Tomcat一个BUG造成CLOSE_WAIT

此问题还未遇见
http://cxytiandi.com/blog/detail/11147
http://www.cnblogs.com/saaav/p/6258831.html

文章目录
  1. 1. 项目假死
  2. 2. Tomcat一个BUG造成CLOSE_WAIT
|