Skip to content

Commit 17a856d

Browse files
committed
Change aggregated log format of pgbench.
Commit 4a39f87 changed the aggregated log format. Problem is, now the explanatory paragraph for the log line in the document is too long. Also the log format included more optional columns, and it's harder to parse the log lines. This commit tries to solve the problems. - There's no optional log columns anymore. If a column is not meaningful with provided pgbench option, it will be presented as 0. - Reorder the log columns so that it's easier to parse them. - Adjust explanatory paragraph for the log line in the doc. Discussion: https://postgr.es/m/flat/202203280757.3tu4ovs3petm%40alvherre.pgsql
1 parent e37ad5f commit 17a856d

File tree

2 files changed

+82
-41
lines changed

2 files changed

+82
-41
lines changed

doc/src/sgml/ref/pgbench.sgml

+40-24
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,9 @@ END;
24012401
format is used for the log files:
24022402

24032403
<synopsis>
2404-
<replaceable>interval_start</replaceable> <replaceable>num_transactions</replaceable> <replaceable>sum_latency</replaceable> <replaceable>sum_latency_2</replaceable> <replaceable>min_latency</replaceable> <replaceable>max_latency</replaceable> { <replaceable>failures</replaceable> | <replaceable>serialization_failures</replaceable> <replaceable>deadlock_failures</replaceable> } <optional> <replaceable>sum_lag</replaceable> <replaceable>sum_lag_2</replaceable> <replaceable>min_lag</replaceable> <replaceable>max_lag</replaceable> <optional> <replaceable>skipped</replaceable> </optional> </optional> <optional> <replaceable>retried</replaceable> <replaceable>retries</replaceable> </optional>
2404+
<replaceable>interval_start</replaceable> <replaceable>num_transactions</replaceable> <replaceable>sum_latency</replaceable> <replaceable>sum_latency_2</replaceable> <replaceable>min_latency</replaceable> <replaceable>max_latency</replaceable>
2405+
<replaceable>sum_lag</replaceable> <replaceable>sum_lag_2</replaceable> <replaceable>min_lag</replaceable> <replaceable>max_lag</replaceable> <replaceable>skipped</replaceable>
2406+
<replaceable>retried</replaceable> <replaceable>retries</replaceable> <replaceable>failures</replaceable> <replaceable>serialization_failures</replaceable> <replaceable>deadlock_failures</replaceable>
24052407
</synopsis>
24062408

24072409
where
@@ -2417,41 +2419,55 @@ END;
24172419
and
24182420
<replaceable>max_latency</replaceable> is the maximum latency within the interval,
24192421
<replaceable>failures</replaceable> is the number of transactions that ended
2420-
with a failed SQL command within the interval. If you use option
2421-
<option>--failures-detailed</option>, instead of the sum of all failed
2422-
transactions you will get more detailed statistics for the failed
2423-
transactions grouped by the following types:
2424-
<replaceable>serialization_failures</replaceable> is the number of
2425-
transactions that got a serialization error and were not retried after this,
2426-
<replaceable>deadlock_failures</replaceable> is the number of transactions
2427-
that got a deadlock error and were not retried after this.
2422+
with a failed SQL command within the interval.
2423+
</para>
2424+
<para>
24282425
The next fields,
24292426
<replaceable>sum_lag</replaceable>, <replaceable>sum_lag_2</replaceable>, <replaceable>min_lag</replaceable>,
2430-
and <replaceable>max_lag</replaceable>, are only present if the <option>--rate</option>
2431-
option is used.
2427+
and <replaceable>max_lag</replaceable>, only meaningful if the <option>--rate</option>
2428+
option is used. Otherwise, they are all 0.0.
24322429
They provide statistics about the time each transaction had to wait for the
24332430
previous one to finish, i.e., the difference between each transaction's
24342431
scheduled start time and the time it actually started.
24352432
The next field, <replaceable>skipped</replaceable>,
2436-
is only present if the <option>--latency-limit</option> option is used, too.
2433+
is only meaningful if the <option>--latency-limit</option> option is used, too. Otherwise it is 0.
24372434
It counts the number of transactions skipped because they would have
24382435
started too late.
2439-
The <replaceable>retried</replaceable> and <replaceable>retries</replaceable>
2440-
fields are present only if the <option>--max-tries</option> option is not
2441-
equal to 1. They report the number of retried transactions and the sum of all
2442-
retries after serialization or deadlock errors within the interval.
2443-
Each transaction is counted in the interval when it was committed.
2436+
</para>
2437+
<para>
2438+
The <replaceable>retried</replaceable>
2439+
and <replaceable>retries</replaceable> fields are only meaningful if
2440+
the <option>--max-tries</option> option is not equal to 1. Otherwise they
2441+
are 0. They report the number of retried transactions and the sum of all
2442+
retries after serialization or deadlock errors within the interval. Each
2443+
transaction is counted in the interval when it was committed.
2444+
</para>
2445+
<para>
2446+
<replaceable>failures</replaceable> is the sum of all failed transactions.
2447+
If <option>--failures-detailed</option> is specified, instead of the sum of
2448+
all failed transactions you will get more detailed statistics for the
2449+
failed transactions grouped by the following types:
2450+
<replaceable>serialization_failures</replaceable> is the number of
2451+
transactions that got a serialization error and were not retried after this,
2452+
<replaceable>deadlock_failures</replaceable> is the number of transactions
2453+
that got a deadlock error and were not retried after this.
2454+
If <option>--failures-detailed</option> is not
2455+
specified, <replaceable>serialization_failures</replaceable>
2456+
and <replaceable>deadlock_failures</replaceable> are always 0.
24442457
</para>
24452458

24462459
<para>
2447-
Here is some example output:
2460+
Here is some example output with following options:
24482461
<screen>
2449-
1345828501 5601 1542744 483552416 61 2573 0
2450-
1345828503 7884 1979812 565806736 60 1479 0
2451-
1345828505 7208 1979422 567277552 59 1391 0
2452-
1345828507 7685 1980268 569784714 60 1398 0
2453-
1345828509 7073 1979779 573489941 236 1411 0
2454-
</screen></para>
2462+
pgbench --aggregate-interval=10 --time=20 --client=10 --log --rate=1000
2463+
--latency-limit=10 --failures-detailed --max-tries=10 test
2464+
</screen>
2465+
2466+
<screen>
2467+
1649114136 5815 27552565 177846919143 1078 21716 2756787 7264696105 0 9661 0 7854 31472 4022 4022 0
2468+
1649114146 5958 28460110 182785513108 1083 20391 2539395 6411761497 0 7268 0 8127 32595 4101 4101 0
2469+
</screen>
2470+
</para>
24552471

24562472
<para>
24572473
Notice that while the plain (unaggregated) log file shows which script

src/bin/pgbench/pgbench.c

+42-17
Original file line numberDiff line numberDiff line change
@@ -4494,6 +4494,17 @@ doLog(TState *thread, CState *st,
44944494

44954495
while ((next = agg->start_time + agg_interval * INT64CONST(1000000)) <= now)
44964496
{
4497+
double lag_sum = 0.0;
4498+
double lag_sum2 = 0.0;
4499+
double lag_min = 0.0;
4500+
double lag_max = 0.0;
4501+
int64 skipped = 0;
4502+
int64 serialization_failures = 0;
4503+
int64 deadlock_failures = 0;
4504+
int64 serialization_or_deadlock_failures = 0;
4505+
int64 retried = 0;
4506+
int64 retries = 0;
4507+
44974508
/* print aggregated report to logfile */
44984509
fprintf(logfile, INT64_FORMAT " " INT64_FORMAT " %.0f %.0f %.0f %.0f",
44994510
agg->start_time / 1000000, /* seconds since Unix epoch */
@@ -4503,27 +4514,41 @@ doLog(TState *thread, CState *st,
45034514
agg->latency.min,
45044515
agg->latency.max);
45054516

4506-
if (failures_detailed)
4507-
fprintf(logfile, " " INT64_FORMAT " " INT64_FORMAT,
4508-
agg->serialization_failures,
4509-
agg->deadlock_failures);
4510-
else
4511-
fprintf(logfile, " " INT64_FORMAT, getFailures(agg));
4512-
45134517
if (throttle_delay)
45144518
{
4515-
fprintf(logfile, " %.0f %.0f %.0f %.0f",
4516-
agg->lag.sum,
4517-
agg->lag.sum2,
4518-
agg->lag.min,
4519-
agg->lag.max);
4520-
if (latency_limit)
4521-
fprintf(logfile, " " INT64_FORMAT, agg->skipped);
4519+
lag_sum = agg->lag.sum;
4520+
lag_sum2 = agg->lag.sum2;
4521+
lag_min = agg->lag.min;
4522+
lag_max = agg->lag.max;
45224523
}
4524+
fprintf(logfile, " %.0f %.0f %.0f %.0f",
4525+
lag_sum,
4526+
lag_sum2,
4527+
lag_min,
4528+
lag_max);
4529+
4530+
if (latency_limit)
4531+
skipped = agg->skipped;
4532+
fprintf(logfile, " " INT64_FORMAT, skipped);
4533+
45234534
if (max_tries != 1)
4524-
fprintf(logfile, " " INT64_FORMAT " " INT64_FORMAT,
4525-
agg->retried,
4526-
agg->retries);
4535+
{
4536+
retried = agg->retried;
4537+
retries = agg->retries;
4538+
}
4539+
fprintf(logfile, " " INT64_FORMAT " " INT64_FORMAT, retried, retries);
4540+
4541+
if (failures_detailed)
4542+
{
4543+
serialization_failures = agg->serialization_failures;
4544+
deadlock_failures = agg->deadlock_failures;
4545+
}
4546+
serialization_or_deadlock_failures = serialization_failures + deadlock_failures;
4547+
fprintf(logfile, " " INT64_FORMAT " " INT64_FORMAT " " INT64_FORMAT,
4548+
serialization_or_deadlock_failures,
4549+
serialization_failures,
4550+
deadlock_failures);
4551+
45274552
fputc('\n', logfile);
45284553

45294554
/* reset data and move to next interval */

0 commit comments

Comments
 (0)