From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Subject: Re: pgbench - minor fix for meta command only scripts
Date: Wed, 13 Jul 2016 10:21:08 +0200 (CEST)
Message-ID: <alpine.DEB.2.20.1607131018210.7486@sto> (raw)
In-Reply-To: <alpine.DEB.2.20.1607130823530.7486@sto>
References: <alpine.DEB.2.20.1607090850120.3412@sto>
<CAB7nPqRZmRbsfdShOLPMGuqU3BeZFbYG5u0jsXv1q+LxLsP5uw@mail.gmail.com>
<alpine.DEB.2.20.1607110653460.12659@sto>
<6016.1468357163@sss.pgh.pa.us>
<alpine.DEB.2.20.1607130823530.7486@sto>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
> The attached patch provides a solution which ensures the return in the right
> condition and after the stat collection. The code structure requires another
> ugly boolean to proceed so as to preserve doing the reconnection between the
> decision that the return must be done and the place where it can be done,
> after reconnecting.
Ooops, the attached patched was the right content but wrongly named:-(
Here it is again with a consistent name.
Sorry for the noise.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:pgbench-no-sql-fix-3.patch (text/x-diff, 1.8K) downloaddiff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 87fb006..8c5df14 100644--- a/src/bin/pgbench/pgbench.c+++ b/src/bin/pgbench/pgbench.c@@ -1766,7 +1766,8 @@ doCustom(TState *thread, CState *st, StatsData *agg)
{
PGresult *res;
Command **commands;
- bool trans_needs_throttle = false;+ bool trans_needs_throttle = false,+ return_before_next_trans = false;
instr_time now;
/*
@@ -1849,6 +1850,8 @@ top:
if (st->listen)
{ /* are we receiver? */
+ bool listened_a_meta = commands[st->state]->type == META_COMMAND;+
if (commands[st->state]->type == SQL_COMMAND)
{
if (debug)
@@ -1892,6 +1895,7 @@ top:
/*
* Read and discard the query result; note this is not included in
* the statement latency numbers.
+ * Should this be done before recording the statement stats?
*/
res = PQgetResult(st->con);
switch (PQresultStatus(res))
@@ -1913,6 +1917,7 @@ top:
{
if (is_connect)
{
+ /* Should transaction stats recorded above count this time? */
PQfinish(st->con);
st->con = NULL;
}
@@ -1942,12 +1947,17 @@ top:
* listen back to true.
*/
st->listen = false;
++ if (listened_a_meta)+ return_before_next_trans = true;+
trans_needs_throttle = (throttle_delay > 0);
}
}
if (st->con == NULL)
{
+ /* Why is connection time is out of transaction time stats? */
instr_time start,
end;
@@ -1969,6 +1979,10 @@ top:
memset(st->prepared, 0, sizeof(st->prepared));
}
+ /* ensure that meta-only scripts sometimes return */+ if (return_before_next_trans)+ return true;+
/*
* This ensures that a throttling delay is inserted before proceeding with
* sql commands, after the first transaction. The first transaction
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: coelho@cri.ensmp.fr, tgl@sss.pgh.pa.us, michael.paquier@gmail.com
Subject: Re: pgbench - minor fix for meta command only scripts
In-Reply-To: <alpine.DEB.2.20.1607131018210.7486@sto>
References: <alpine.DEB.2.20.1607090850120.3412@sto> <CAB7nPqRZmRbsfdShOLPMGuqU3BeZFbYG5u0jsXv1q+LxLsP5uw@mail.gmail.com> <alpine.DEB.2.20.1607110653460.12659@sto> <6016.1468357163@sss.pgh.pa.us> <alpine.DEB.2.20.1607130823530.7486@sto> <alpine.DEB.2.20.1607131018210.7486@sto>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox