On Mon, 14 Jun 2021 00:42:12 +0000
"[email protected]" <[email protected]> wrote:
> Dear Fabien,
>
> Thank you for replying!
>
> > Hmmm. Possibly. Another option could be not to report anything after some
> > errors. I'm not sure, because it would depend on the use case. I guess the
> > command returned an error status as well.
>
> I did not know any use cases and decisions , but I vote to report nothing
> when error occurs.
I would prefer to abort the thread whose connection got an error and report
results for other threads, as handled when doConnect fails in CSTATE_START_TX
state.
In this case, we have to set the state to CSTATE_ABORT before going to 'done'
as fixed in the attached patch, in order to ensure that exit status is 2 and the
result reports "pgbench: fatal: Run was aborted; the above results are
incomplete."
Otherwise, if we want pgbench to exit immediately when a connection error
occurs,
we have tocall exit(1) to ensure the exit code is 1, of course. Anyway, it is
wrong
that thecurrent pgbench exit successfully with exit code 0 when doConnnect
fails.
Regards,
Yugo Nagata
--
Yugo NAGATA <[email protected]>
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index d7479925cb..35b67265c7 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6581,6 +6581,7 @@ threadRun(void *arg)
* than coldly exiting with an error message.
*/
THREAD_BARRIER_WAIT(&barrier);
+ state[i].state = CSTATE_ABORTED;
goto done;
}
}
@@ -6647,6 +6648,7 @@ threadRun(void *arg)
if (sock < 0)
{
pg_log_error("invalid socket: %s", PQerrorMessage(st->con));
+ st->state = CSTATE_ABORTED;
goto done;
}
@@ -6708,6 +6710,7 @@ threadRun(void *arg)
}
/* must be something wrong */
pg_log_fatal("%s() failed: %m", SOCKET_WAIT_METHOD);
+ state[0].state = CSTATE_ABORTED;
goto done;
}
}
@@ -6733,6 +6736,7 @@ threadRun(void *arg)
if (sock < 0)
{
pg_log_error("invalid socket: %s", PQerrorMessage(st->con));
+ st->state = CSTATE_ABORTED;
goto done;
}