From cae0f3c40554e85cd004732f3f57b9cb936136d2 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 11 Oct 2024 13:40:23 +0900 Subject: [PATCH] pgbench: Improve result outputs related to failed transactions. Previously, per-script statistics were never output when all transactions failed due to serialization or deadlock errors. However, it is reasonable to report such information if there are ones even when there are no successful transaction since these failed transactions are now objects to be reported. Meanwhile, if the total number of successful, skipped, and failed transactions is zero, we don't have to report the number of failed transactions as similar to the number of skipped transactions, which avoids to print "NaN%" in lines on failed transaction reports. Also, the number of transactions in per-script results now includes skipped and failed transactions. It prevents to print "total of NaN%" when any transactions are not successfully processed. The number of transactions actually processed per-script and TPS based on it are now output explicitly in a separate line. Author: Yugo Nagata Reviewed-by: Tatsuo Ishii Discussion: https://postgr.es/m/20240921003544.2436ef8da9c5c8cb963c651b%40sraoss.co.jp --- src/bin/pgbench/pgbench.c | 85 ++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index e658d060add..826f7e093db 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -6391,6 +6391,13 @@ printResults(StatsData *total, total->cnt); } + /* + * Remaining stats are nonsensical if we failed to execute any xacts due + * to others than serialization or deadlock errors + */ + if (total_cnt <= 0) + return; + printf("number of failed transactions: " INT64_FORMAT " (%.3f%%)\n", failures, 100.0 * failures / total_cnt); @@ -6412,10 +6419,6 @@ printResults(StatsData *total, printf("total number of retries: " INT64_FORMAT "\n", total->retries); } - /* Remaining stats are nonsensical if we failed to execute any xacts */ - if (total->cnt + total->skipped <= 0) - return; - if (throttle_delay && latency_limit) printf("number of transactions skipped: " INT64_FORMAT " (%.3f%%)\n", total->skipped, 100.0 * total->skipped / total_cnt); @@ -6483,45 +6486,53 @@ printResults(StatsData *total, printf("SQL script %d: %s\n" " - weight: %d (targets %.1f%% of total)\n" - " - " INT64_FORMAT " transactions (%.1f%% of total, tps = %f)\n", + " - " INT64_FORMAT " transactions (%.1f%% of total)\n", i + 1, sql_script[i].desc, sql_script[i].weight, 100.0 * sql_script[i].weight / total_weight, - sstats->cnt, - 100.0 * sstats->cnt / total->cnt, - sstats->cnt / bench_duration); + script_total_cnt, + 100.0 * script_total_cnt / total_cnt); - printf(" - number of failed transactions: " INT64_FORMAT " (%.3f%%)\n", - script_failures, - 100.0 * script_failures / script_total_cnt); - - if (failures_detailed) + if (script_total_cnt > 0) { - printf(" - number of serialization failures: " INT64_FORMAT " (%.3f%%)\n", - sstats->serialization_failures, - (100.0 * sstats->serialization_failures / - script_total_cnt)); - printf(" - number of deadlock failures: " INT64_FORMAT " (%.3f%%)\n", - sstats->deadlock_failures, - (100.0 * sstats->deadlock_failures / - script_total_cnt)); + printf(" - number of transactions actually pocessed: " INT64_FORMAT " (tps = %f)\n", + sstats->cnt, sstats->cnt / bench_duration); + + printf(" - number of failed transactions: " INT64_FORMAT " (%.3f%%)\n", + script_failures, + 100.0 * script_failures / script_total_cnt); + + if (failures_detailed) + { + printf(" - number of serialization failures: " INT64_FORMAT " (%.3f%%)\n", + sstats->serialization_failures, + (100.0 * sstats->serialization_failures / + script_total_cnt)); + printf(" - number of deadlock failures: " INT64_FORMAT " (%.3f%%)\n", + sstats->deadlock_failures, + (100.0 * sstats->deadlock_failures / + script_total_cnt)); + } + + /* + * it can be non-zero only if max_tries is not equal to + * one + */ + if (max_tries != 1) + { + printf(" - number of transactions retried: " INT64_FORMAT " (%.3f%%)\n", + sstats->retried, + 100.0 * sstats->retried / script_total_cnt); + printf(" - total number of retries: " INT64_FORMAT "\n", + sstats->retries); + } + + if (throttle_delay && latency_limit) + printf(" - number of transactions skipped: " INT64_FORMAT " (%.3f%%)\n", + sstats->skipped, + 100.0 * sstats->skipped / script_total_cnt); + } - - /* it can be non-zero only if max_tries is not equal to one */ - if (max_tries != 1) - { - printf(" - number of transactions retried: " INT64_FORMAT " (%.3f%%)\n", - sstats->retried, - 100.0 * sstats->retried / script_total_cnt); - printf(" - total number of retries: " INT64_FORMAT "\n", - sstats->retries); - } - - if (throttle_delay && latency_limit && script_total_cnt > 0) - printf(" - number of transactions skipped: " INT64_FORMAT " (%.3f%%)\n", - sstats->skipped, - 100.0 * sstats->skipped / script_total_cnt); - printSimpleStats(" - latency", &sstats->latency); }