Merged
Conversation
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a shutdown issue where the EngineQosTimer continued running after Besu initiated shutdown, preventing the process from exiting cleanly. The fix introduces a stop mechanism that cancels the QoS timer before closing the HTTP server, allowing the vertx event loop to terminate properly.
Changes:
- Added a
stop()method to the QosTimer that sets a volatile stopped flag and cancels the vertx timer - Introduced a default
stop()method in the EngineCallListener interface for backward compatibility - Modified EngineJsonRpcService to stop the EngineCallListener before shutting down the HTTP server
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| QosTimer.java | Added volatile stopped flag and stop() method to cancel timer and prevent rescheduling |
| EngineCallListener.java | Added default stop() method to interface |
| EngineQosTimer.java | Implemented stop() by delegating to underlying QosTimer |
| ExecutionEngineJsonRpcMethod.java | Added getter to expose engineCallListener field |
| EngineJsonRpcService.java | Added stopEngineCallListener() to cancel timer before HTTP server shutdown |
| CHANGELOG.md | Added entry documenting the fix |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/QosTimer.java
Show resolved
Hide resolved
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/EngineJsonRpcService.java
Show resolved
Hide resolved
usmansaleem
reviewed
Mar 2, 2026
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/EngineJsonRpcService.java
Show resolved
Hide resolved
usmansaleem
approved these changes
Mar 2, 2026
Contributor
usmansaleem
left a comment
There was a problem hiding this comment.
LGTM - I would add a quick test for QosTimer.stop() though (that it prevents rescheduling).
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR description
QosTimer.java Added a volatile boolean stopped flag and a stop() method that cancels the vertx timer. The timer handler and resetTimerHandler() both check the flag before rescheduling, and resetTimer() returns early if stopped.
EngineCallListener.java Added default void stop() {} so all listeners can be stopped without breaking existing implementations.
EngineQosTimer.java stop() delegates to qosTimer.stop().
ExecutionEngineJsonRpcMethod.java — Added getEngineCallListener() getter to expose the protected field.
EngineJsonRpcService.java — stop() now calls stopEngineCallListener() first, which finds any ExecutionEngineJsonRpcMethod in the methods map and calls stop() on its listener. This cancels the QosTimer before the HTTP server is
closed, allowing the vertx eventloop to shut down cleanly.
The shutdown sequence now works:
Fixed Issue(s)
Before this PR, running besu locally would frequently not shutdown cleanly eg besu this, and continues logging the engine message every 120 seconds, and I needed to kill the process.
after this PR, besu logs this and successfully stops:
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests