Skip to content

Commit e986810

Browse files
committed
fix the bug of not stop solidity node gracefully
1 parent d188b51 commit e986810

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

framework/src/main/java/org/tron/common/application/ApplicationImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.tron.core.db.Manager;
1111
import org.tron.core.net.TronNetService;
1212
import org.tron.core.services.event.EventService;
13+
import org.tron.program.SolidityNode;
1314

1415
@Slf4j(topic = "app")
1516
@Component
@@ -33,6 +34,9 @@ public class ApplicationImpl implements Application {
3334
@Autowired
3435
private ConsensusService consensusService;
3536

37+
@Autowired(required = false)
38+
private SolidityNode solidityNode;
39+
3640
private final CountDownLatch shutdown = new CountDownLatch(1);
3741

3842
/**
@@ -55,6 +59,9 @@ public void shutdown() {
5559
}
5660
consensusService.stop();
5761
eventService.close();
62+
if (solidityNode != null) {
63+
solidityNode.close();
64+
}
5865
dbManager.close();
5966
shutdown.countDown();
6067
}

framework/src/main/java/org/tron/program/SolidityNode.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,26 @@ public void onApplicationEvent(ContextClosedEvent event) {
6969
flag = false; // invoke earlier than @PreDestroy
7070
}
7171

72-
@PreDestroy
73-
private void shutdown() {
72+
public void close() {
7473
flag = false;
7574
if (databaseGrpcClient != null) {
7675
databaseGrpcClient.shutdown();
7776
}
77+
// Interrupt get-block immediately: it may be stuck in blockQueue.put() (full queue,
78+
// process-block stopped) or in a gRPC blocking stub call.
79+
// Do NOT interrupt process-block: let it finish its current pushVerifiedBlock naturally
80+
// (flag=false causes the while-loop to exit within 1-2 s) so the DB flush can complete
81+
// cleanly before ApplicationImpl.shutdown() tears down the underlying executor.
82+
getBlockExecutor.shutdownNow();
7883
ExecutorServiceManager.shutdownAndAwaitTermination(getBlockExecutor, getBlockName);
7984
ExecutorServiceManager.shutdownAndAwaitTermination(processBlockExecutor, processBlockName);
8085
}
8186

87+
@PreDestroy
88+
private void shutdown() {
89+
close();
90+
}
91+
8292
public void run() {
8393
try {
8494
databaseGrpcClient = new DatabaseGrpcClient(CommonParameter.getInstance().getTrustNodeAddr());

0 commit comments

Comments
 (0)