Skip to content

Commit 6914a33

Browse files
committed
Fix assertion failure in pgbench when handling multiple pipeline sync messages.
Previously, when running pgbench in pipeline mode with a custom script that triggered retriable errors (e.g., serialization errors), an assertion failure could occur: Assertion failed: (res == ((void*)0)), function discardUntilSync, file pgbench.c, line 3515. The root cause was that pgbench incorrectly assumed only a single pipeline sync message would be received at the end. In reality, multiple pipeline sync messages can be sent and must be handled properly. This commit fixes the issue by updating pgbench to correctly process multiple pipeline sync messages, preventing the assertion failure. Back-patch to v15, where the bug was introduced. Author: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Tatsuo Ishii <ishii@postgresql.org> Discussion: https://postgr.es/m/CAHGQGwFAX56Tfx+1ppo431OSWiLLuW72HaGzZ39NkLkop6bMzQ@mail.gmail.com Backpatch-through: 15
1 parent 23dc277 commit 6914a33

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,8 @@ doRetry(CState *st, pg_time_usec_t *now)
34803480
static int
34813481
discardUntilSync(CState *st)
34823482
{
3483+
bool received_sync = false;
3484+
34833485
/* send a sync */
34843486
if (!PQpipelineSync(st->con))
34853487
{
@@ -3494,10 +3496,16 @@ discardUntilSync(CState *st)
34943496
PGresult *res = PQgetResult(st->con);
34953497

34963498
if (PQresultStatus(res) == PGRES_PIPELINE_SYNC)
3499+
received_sync = true;
3500+
else if (received_sync)
34973501
{
3498-
PQclear(res);
3499-
res = PQgetResult(st->con);
3502+
/*
3503+
* PGRES_PIPELINE_SYNC must be followed by another
3504+
* PGRES_PIPELINE_SYNC or NULL; otherwise, assert failure.
3505+
*/
35003506
Assert(res == NULL);
3507+
3508+
PQclear(res);
35013509
break;
35023510
}
35033511
PQclear(res);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy