Browse Source

Fix deadlock in master/worker caused by close method (#8361)

2.0.7-release
Wenjun Ruan 3 years ago committed by GitHub
parent
commit
de476edc38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
  2. 8
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java

9
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java

@ -229,16 +229,17 @@ public class MasterServer implements IStoppable {
// close spring Context and will invoke method with @PreDestroy annotation to destory beans. like ServerNodeManager,HostManager,TaskResponseService,CuratorZookeeperClient,etc // close spring Context and will invoke method with @PreDestroy annotation to destory beans. like ServerNodeManager,HostManager,TaskResponseService,CuratorZookeeperClient,etc
springApplicationContext.close(); springApplicationContext.close();
logger.info("springApplicationContext close"); logger.info("springApplicationContext close");
} catch (Exception e) {
logger.error("master server stop exception ", e);
} finally {
try { try {
// thread sleep 60 seconds for quietly stop // thread sleep 60 seconds for quietly stop
Thread.sleep(60000L); Thread.sleep(60000L);
} catch (Exception e) { } catch (Exception e) {
logger.warn("thread sleep exception ", e); logger.warn("thread sleep exception ", e);
} }
System.exit(1); // Since close will be executed in hook, so we can't use System.exit here.
Runtime.getRuntime().halt(0);
} catch (Exception e) {
logger.error("master server stop exception ", e);
Runtime.getRuntime().halt(1);
} }
} }

8
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java

@ -200,16 +200,16 @@ public class WorkerServer implements IStoppable {
this.alertClientService.close(); this.alertClientService.close();
this.springApplicationContext.close(); this.springApplicationContext.close();
logger.info("springApplicationContext close"); logger.info("springApplicationContext close");
} catch (Exception e) {
logger.error("worker server stop exception ", e);
} finally {
try { try {
// thread sleep 60 seconds for quietly stop // thread sleep 60 seconds for quietly stop
Thread.sleep(60000L); Thread.sleep(60000L);
} catch (Exception e) { } catch (Exception e) {
logger.warn("thread sleep exception ", e); logger.warn("thread sleep exception ", e);
} }
System.exit(1); Runtime.getRuntime().halt(0);
} catch (Exception e) {
logger.error("worker server stop exception ", e);
Runtime.getRuntime().halt(1);
} }
} }

Loading…
Cancel
Save