背景
前几天有同事反馈,说生产上的定时任务好像卡住了,没有执行。
上服务器,查看应用日志,定时任务确实没有执行。
分析
这种情况,第一时间先把线程dump文件导出来
分析dump文件,发现线程一直在执行sess.execCommand方法
看来是这个方法的问题waitForChannelSuccessOrFailure。
赶紧看一下这个方法的源码
private final void waitForChannelSuccessOrFailure(Channel c) throws IOException {
synchronized(c) {
while(c.successCounter == 0 && c.failedCounter == 0) {
if(c.state != 2) {
String detail = c.getReasonClosed();
if(detail == null) {
detail = "state: " + c.state;
}
throw new IOException("This SSH2 channel is not open (" + detail + ")");