From b2ed8edeecd715c8a23ae462da843578e5cde7f4 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 28 Jul 2015 11:30:23 +0300 Subject: [PATCH] Fix bug in collecting total_latencies from all threads in pgbench. This was broken in 1bc90f7a, which removed the thread-emulation. With modest -j and -c settings the result were usually close enough that you wouldn't notice it easily, but with a high enough thread count it would access uninitialized memory and crash. Per report from Andres Freund offlist. --- src/bin/pgbench/pgbench.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index e839fa3656..3b8a80fa7a 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3456,8 +3456,8 @@ main(int argc, char **argv) for (j = 0; j < thread->nstate; j++) { total_xacts += thread->state[j].cnt; - total_latencies += thread->state[i].txn_latencies; - total_sqlats += thread->state[i].txn_sqlats; + total_latencies += thread->state[j].txn_latencies; + total_sqlats += thread->state[j].txn_sqlats; } } disconnect_all(state, nclients);