Fix possible lockup in pgbench with -R.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Jul 2019 19:17:03 +0000 (15:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Jul 2019 19:17:03 +0000 (15:17 -0400)
pgbench would sometimes get stuck waiting forever after its last
client thread terminated, due to failing to check for there being
nothing more to wait for.

Bug introduced during refactoring in v10 (I didn't bother to try to
assign blame to a specific commit).  It's already repaired in
HEAD/v12 thanks to commit 3bac77c48, but v10 and v11 need this fix.

Fabien Coelho, per report from Tomas Vondra; reviewed by
Yoshikazu Imai

Discussion: https://postgr.es/m/cc5d76c1-6144-bbed-ad1b-961d13d88f3b@2ndquadrant.com

src/bin/pgbench/pgbench.c

index 2bdfc89d2a52d878fe88dc81e1486f43394b8239..0c1b01ecdae08d5db52123b2ecc8b1f1d8823c71 100644 (file)
@@ -4515,6 +4515,10 @@ threadRun(void *arg)
                        }
                }
 
+               /* under throttling we may have finished the last client above */
+               if (remains == 0)
+                       break;
+
                /* also wake up to print the next progress report on time */
                if (progress && min_usec > 0 && thread->tid == 0)
                {