From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Yugo NAGATA <nagata@sraoss.co.jp>
Cc: Gregory Smith <gregsmithpgsql@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: david.christensen@crunchydata.com
Subject: Re: pgbench logging broken by time logic changes
Date: Wed, 16 Jun 2021 21:11:41 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2106162102030.2407635@pseudo> (raw)
In-Reply-To: <20210617025138.04a35c3ae9a6cd40c077cea0@sraoss.co.jp>
References: <CAHLJuCW_8Vpcr0=t6O_gozrg3wXXWXZXDioYJd3NhvKriqgpfQ@mail.gmail.com>
<20210617025138.04a35c3ae9a6cd40c077cea0@sraoss.co.jp>
> pg_time_now(). This uses INSTR_TIME_SET_CURRENT in it, but this macro
> can call clock_gettime(CLOCK_MONOTONIC[_RAW], ) instead of gettimeofday
> or clock_gettime(CLOCK_REALTIME, ). When CLOCK_MONOTONIC[_RAW] is used,
> clock_gettime doesn't return epoch time. Therefore, we can use
> INSTR_TIME_SET_CURRENT aiming to calculate a duration, but we should
> not have used this to get the current timestamp.
>
> I think we can fix this issue by using gettimeofday for logging as before
> this was changed. I attached the patch.
I cannot say that I'm thrilled by having multiple tv stuff back in several
place. I can be okay with one, though. What about the attached? Does it
make sense?
--
Fabien.
Attachments:pgbench-epoch-1.patch (text/x-diff, 538B) downloaddiff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex d7479925cb..5fe2a9286f 100644--- a/src/bin/pgbench/pgbench.c+++ b/src/bin/pgbench/pgbench.c@@ -672,11 +672,11 @@ static const PsqlScanCallbacks pgbench_callbacks = {
static inline pg_time_usec_t
pg_time_now(void)
{
- instr_time now;+ struct timeval tv;- INSTR_TIME_SET_CURRENT(now);+ gettimeofday(&tv, NULL);- return (pg_time_usec_t) INSTR_TIME_GET_MICROSEC(now);+ return tv.tv_sec * 1000000 + tv.tv_usec;
}
static inline void
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: coelho@cri.ensmp.fr, nagata@sraoss.co.jp, gregsmithpgsql@gmail.com, david.christensen@crunchydata.com
Subject: Re: pgbench logging broken by time logic changes
In-Reply-To: <alpine.DEB.2.22.394.2106162102030.2407635@pseudo>
* 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