Skip to content

Conversation

@heifner
Copy link
Contributor

@heifner heifner commented Apr 7, 2025

Interrupt speculative transaction execution when a block is received or on ctrl-c.

Along with the existing interrupt of transactions in a block being validated, also interrupt speculative trxs so that processing of incoming block can start immediately.

Example:

debug 2025-04-08T14:39:46.595 net-3     net_plugin.cpp:4029           operator()           ] post process_incoming_block to app thread, block 441
debug 2025-04-08T14:39:46.595 net-3     controller.cpp:4563           interrupt_transactio ] Interrupting trx...
debug 2025-04-08T14:39:46.595 net-2     net_plugin.cpp:2855           operator()           ] ["localhost:9883 - f7f9514" - 4 127.0.0.1:60824] bcast block 441
debug 2025-04-08T14:39:46.596 nodeos    producer_plugin.cpp:2593      handle_push_result   ] [TRX_TRACE] Speculative execution COULD NOT FIT, elapsed 568us, tx: 08b18c0b53cab805495586bba2c53b6ed1dd390c7caad2b4a840c2036410ed4b RETRYING
debug 2025-04-08T14:39:46.596 net-2     net_plugin.cpp:1999           operator()           ] Connection - 4 - done sending block 441
debug 2025-04-08T14:39:46.596 nodeos    producer_plugin.cpp:971       restart_speculative_ ] Restarting exhausted speculative block #441
debug 2025-04-08T14:39:46.596 nodeos    producer_plugin.cpp:312       report               ] Block #441 defproducerb trx idle: 439611us out of 455626us, success: 12, 14269us, fail: 0, 0us, transient: 0, 0us, other: 1745us
debug 2025-04-08T14:39:46.596 nodeos    producer_plugin.cpp:2928      schedule_delayed_pro ] Scheduling Speculative/Production Change at 2025-04-08T14:39:47.096
debug 2025-04-08T14:39:46.596 nodeos    controller.cpp:4448           operator()           ] applying 1 fork db blocks from 441:000001b96c9ef0518f0c1493d79d8ff0c1e093185d886e2a39d6e3a69653e4c6 to 441:000001b96c9ef0518f0c1493d79d8ff0c1e093185d886e2a39d6e3a69653e4c6
...
info  2025-04-08T14:39:46.603 nodeos    controller.cpp:3558           log_applied          ] Received block 6c9ef0518f0c1493... #441 @ 2025-04-08T14:39:47.000 signed by defproducerb [trxs: 12, lib: 439, net: 1728, cpu: 5818 us, elapsed: 3348 us, applying time: 6518 us, latency: -396 ms]
debug 2025-04-08T14:39:46.603 nodeos    producer_plugin.cpp:2236      start_block          ] Starting block #442 2025-04-08T14:39:47.500 producer defproducerb, deadline 2025-04-08T14:39:47.103

Resolves #1170

@heifner heifner requested review from greg7mdp and linh2931 April 7, 2025 17:55
@heifner heifner added the OCI Work exclusive to OCI team label Apr 7, 2025
@heifner heifner linked an issue Apr 7, 2025 that may be closed by this pull request
@ericpassmore
Copy link
Contributor

Note:start
category: Other
component: Internal
summary: Add interrupt of speculative transactions interrupting when a block is received.
Note:end

@heifner heifner marked this pull request as draft April 8, 2025 14:28
my->chain_plug->chain().interrupt_apply_block_transaction();
if (my->_is_savanna_active) { // interrupt during transition causes issues, so only allow after transition
if (fork_db_add_result == fork_db_add_t::appended_to_head) {
fc_tlog(_log, "new head block received");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have this message?

Suggested change
fc_tlog(_log, "new head block received");
fc_tlog(_log, "new head block received, interrupting transaction");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heifner heifner marked this pull request as ready for review April 9, 2025 18:22
Base automatically changed from GH-1323-interrupt-read-only-trx to main April 14, 2025 16:57
Copy link
Contributor

@linh2931 linh2931 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests to verify the new interruption?

@heifner
Copy link
Contributor Author

heifner commented Apr 15, 2025

Do we have tests to verify the new interruption?

Every savanna integration test exercises the interrupt. Every incoming block has the potential to interrupt a transaction.

@heifner heifner merged commit 2f236ca into main Apr 16, 2025
36 checks passed
@heifner heifner deleted the GH-1170-interrupt-spec-trx branch April 16, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCI Work exclusive to OCI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid block processing delays due to speculative trx execution

5 participants