]> granicus.if.org Git - postgresql/commitdiff
Fix bug in collecting total_latencies from all threads in pgbench.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 28 Jul 2015 08:30:23 +0000 (11:30 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 28 Jul 2015 08:30:23 +0000 (11:30 +0300)
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

index e839fa365672b6142e09648f335cef6183b59403..3b8a80fa7ad44f3d0af23b7c68eccbc12448146a 100644 (file)
@@ -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);