From 73c2721964b678da029ebeb83464fd34ed112545 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 4 Jan 2021 13:28:32 -0600 Subject: [PATCH 1/3] Return failure traces when running with amqp_trx_plugin --- plugins/producer_plugin/producer_plugin.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 40a266b90d9..6a3b34f5a96 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -491,7 +491,8 @@ class producer_plugin_impl : public std::enable_shared_from_this next, - RetryLaterFunc retry_later) + RetryLaterFunc retry_later, + bool return_failure_trace = false) { bool exhausted = false; chain::controller& chain = chain_plug->chain(); @@ -546,8 +547,12 @@ class producer_plugin_impl : public std::enable_shared_from_thisexcept->dynamic_copy_exception(); - send_response( e_ptr ); + if( return_failure_trace ) { + send_response( trace ); + } else { + auto e_ptr = trace->except->dynamic_copy_exception(); + send_response( e_ptr ); + } } } else { if( persist_until_expired ) { @@ -2094,7 +2099,8 @@ bool producer_plugin::execute_incoming_transaction(const chain::transaction_meta }; const bool persist_until_expired = false; - bool exhausted = !my->process_incoming_transaction_async( trx, persist_until_expired, std::move(next), retry_later_func ); + const bool return_failure_trace = true; + bool exhausted = !my->process_incoming_transaction_async( trx, persist_until_expired, std::move(next), retry_later_func, return_failure_trace ); if( exhausted ) { if( my->_pending_block_mode == pending_block_mode::producing ) { my->schedule_maybe_produce_block( true ); From 9d20bc936f96eeb4911ea251e0a04f9618b9107c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 4 Jan 2021 14:37:06 -0600 Subject: [PATCH 2/3] Update trx logging to report correct log message when returning transaction_trace failures --- plugins/producer_plugin/producer_plugin.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 6a3b34f5a96..1bb9a5abc6d 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -458,18 +458,20 @@ class producer_plugin_impl : public std::enable_shared_from_this& response) { next(response); - if (response.contains()) { + if (response.contains() || response.get()->except) { _transaction_ack_channel.publish(priority::low, std::pair(response.get(), trx)); if (_pending_block_mode == pending_block_mode::producing) { fc_dlog(_trx_failed_trace_log, "[TRX_TRACE] Block ${block_num} for producer ${prod} is REJECTING tx: ${txid} : ${why} ", ("block_num", chain.head_block_num() + 1) ("prod", get_pending_block_producer()) ("txid", trx->id()) - ("why",response.get()->what())); + ("why", response.contains() ? + response.get()->what() : response.get()->except->what())); } else { fc_dlog(_trx_failed_trace_log, "[TRX_TRACE] Speculative execution is REJECTING tx: ${txid} : ${why} ", ("txid", trx->id()) - ("why",response.get()->what())); + ("why", response.contains() ? + response.get()->what() : response.get()->except->what())); } } else { _transaction_ack_channel.publish(priority::low, std::pair(nullptr, trx)); From a7a9fe4a470be8254c44550a97b9f618e8f4b038 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 4 Jan 2021 16:55:44 -0600 Subject: [PATCH 3/3] Report exception failure in logging and response --- plugins/producer_plugin/producer_plugin.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 1bb9a5abc6d..0d12a0ec1bc 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -458,23 +458,28 @@ class producer_plugin_impl : public std::enable_shared_from_this& response) { next(response); - if (response.contains() || response.get()->except) { - _transaction_ack_channel.publish(priority::low, std::pair(response.get(), trx)); + + fc::exception_ptr except_ptr; + if (response.contains()) { + except_ptr = response.get(); + } else if (response.get()->except) { + except_ptr = response.get()->except->dynamic_copy_exception(); + } + _transaction_ack_channel.publish(priority::low, std::pair(except_ptr, trx)); + + if (except_ptr) { if (_pending_block_mode == pending_block_mode::producing) { fc_dlog(_trx_failed_trace_log, "[TRX_TRACE] Block ${block_num} for producer ${prod} is REJECTING tx: ${txid} : ${why} ", ("block_num", chain.head_block_num() + 1) ("prod", get_pending_block_producer()) ("txid", trx->id()) - ("why", response.contains() ? - response.get()->what() : response.get()->except->what())); + ("why", except_ptr->what())); } else { fc_dlog(_trx_failed_trace_log, "[TRX_TRACE] Speculative execution is REJECTING tx: ${txid} : ${why} ", ("txid", trx->id()) - ("why", response.contains() ? - response.get()->what() : response.get()->except->what())); + ("why", except_ptr->what())); } } else { - _transaction_ack_channel.publish(priority::low, std::pair(nullptr, trx)); if (_pending_block_mode == pending_block_mode::producing) { fc_dlog(_trx_successful_trace_log, "[TRX_TRACE] Block ${block_num} for producer ${prod} is ACCEPTING tx: ${txid}", ("block_num", chain.head_block_num() + 1)