-
Notifications
You must be signed in to change notification settings - Fork 0
fix(net): fix RejectedExecutionException during shutdown trxHandlePool #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||||||||||||||||||||||||||
| import java.util.concurrent.BlockingQueue; | ||||||||||||||||||||||||||||||
| import java.util.concurrent.ExecutorService; | ||||||||||||||||||||||||||||||
| import java.util.concurrent.LinkedBlockingQueue; | ||||||||||||||||||||||||||||||
| import java.util.concurrent.RejectedExecutionException; | ||||||||||||||||||||||||||||||
| import java.util.concurrent.ScheduledExecutorService; | ||||||||||||||||||||||||||||||
| import java.util.concurrent.TimeUnit; | ||||||||||||||||||||||||||||||
| import lombok.Getter; | ||||||||||||||||||||||||||||||
|
|
@@ -44,6 +45,7 @@ public class TransactionsMsgHandler implements TronMsgHandler { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private BlockingQueue<Runnable> queue = new LinkedBlockingQueue(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private volatile boolean isClosed = false; | ||||||||||||||||||||||||||||||
| private int threadNum = Args.getInstance().getValidateSignThreadNum(); | ||||||||||||||||||||||||||||||
| private final String trxEsName = "trx-msg-handler"; | ||||||||||||||||||||||||||||||
| private ExecutorService trxHandlePool = ExecutorServiceManager.newThreadPoolExecutor( | ||||||||||||||||||||||||||||||
|
|
@@ -58,8 +60,14 @@ public void init() { | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public void close() { | ||||||||||||||||||||||||||||||
| ExecutorServiceManager.shutdownAndAwaitTermination(trxHandlePool, trxEsName); | ||||||||||||||||||||||||||||||
| isClosed = true; | ||||||||||||||||||||||||||||||
| // Stop the scheduler first so no new tasks are drained from smartContractQueue. | ||||||||||||||||||||||||||||||
| ExecutorServiceManager.shutdownAndAwaitTermination(smartContractExecutor, smartEsName); | ||||||||||||||||||||||||||||||
| // Then shutdown the worker pool to finish already-submitted tasks. | ||||||||||||||||||||||||||||||
| ExecutorServiceManager.shutdownAndAwaitTermination(trxHandlePool, trxEsName); | ||||||||||||||||||||||||||||||
|
0xbigapple marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| // Discard any remaining items and release references. | ||||||||||||||||||||||||||||||
| smartContractQueue.clear(); | ||||||||||||||||||||||||||||||
|
0xbigapple marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| queue.clear(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public boolean isBusy() { | ||||||||||||||||||||||||||||||
|
|
@@ -68,6 +76,10 @@ public boolean isBusy() { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||
| public void processMessage(PeerConnection peer, TronMessage msg) throws P2pException { | ||||||||||||||||||||||||||||||
| if (isClosed) { | ||||||||||||||||||||||||||||||
| logger.warn("TransactionsMsgHandler is closed, drop message"); | ||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| TransactionsMessage transactionsMessage = (TransactionsMessage) msg; | ||||||||||||||||||||||||||||||
|
Comment on lines
+79
to
83
|
||||||||||||||||||||||||||||||
| if (isClosed) { | |
| logger.warn("TransactionsMsgHandler is closed, drop message"); | |
| return; | |
| } | |
| TransactionsMessage transactionsMessage = (TransactionsMessage) msg; | |
| TransactionsMessage transactionsMessage = (TransactionsMessage) msg; | |
| if (isClosed) { | |
| for (Transaction trx : transactionsMessage.getTransactions().getTransactionsList()) { | |
| Item item = new Item(new TransactionMessage(trx).getMessageId(), InventoryType.TRX); | |
| peer.getAdvInvRequest().remove(item); | |
| } | |
| logger.warn("TransactionsMsgHandler is closed, drop message"); | |
| return; | |
| } |
Copilot
AI
Apr 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RejectedExecutionException catch logs only a generic message and drops the exception details. Including e (or at least e.getMessage()) in the log will make shutdown/rejection issues diagnosable in production, especially since this path is explicitly handling a failure mode.
| logger.warn("Submit task to {} failed", trxEsName); | |
| logger.warn("Submit task to {} failed", trxEsName, e); |
Uh oh!
There was an error while loading. Please reload this page.