Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lribN-0003jq-9G for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Jun 2021 14:57:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lribL-0002pC-8K for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Jun 2021 14:57:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lribL-0002nN-0d for pgsql-hackers@lists.postgresql.org; Fri, 11 Jun 2021 14:57:39 +0000 Received: from sfr-1.cri.mines-paristech.fr ([77.158.180.225] helo=smtp.cri.ensmp.fr) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lribI-0007lZ-Qo for pgsql-hackers@lists.postgresql.org; Fri, 11 Jun 2021 14:57:38 +0000 Received: from petersbourg.cri.ensmp.fr (petersbourg.cri.ensmp.fr [10.2.14.5]) by smtp.cri.ensmp.fr (Postfix) with ESMTPSA id 59A81C001C; Fri, 11 Jun 2021 16:59:28 +0200 (CEST) Date: Fri, 11 Jun 2021 16:57:35 +0200 (CEST) From: Fabien COELHO X-X-Sender: fabien@pseudo To: "kuroda.hayato@fujitsu.com" cc: "'pgsql-hackers@lists.postgresql.org'" Subject: Re: pgbench bug candidate: negative "initial connection time" In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Hayato-san, > I played pgbench with wrong parameters, That's good:-) > and I found bug-candidate. > > 1. Do initdb and start. > 2. Initialize schema and data with "scale factor" = 1. > 3. execute following command many times: > > $ pgbench -c 101 -j 10 postgres > > Then, sometimes the negative " initial connection time" was returned. > Lateyncy average is also strange. > > ``` > $ pgbench -c 101 -j 10 postgres > starting vacuum...end. > pgbench: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: sorry, too many clients already Hmmm. AFAICR there was a decision to generate a report even if something went very wrong, in this case some client could not connect, so some values are not initialized, hence the absurd figures, as you show below. Maybe we should revisit this decision. > initial connection time = -372896921.586 ms > I sought pgbench.c and found a reason. > When a thread failed to get some connections, they do not fill any values to thread->bench_start in threadRun(). > And if the failure is caused in the final thread (this means threads[nthreads - 1]->bench_start is zero), > the following if-statement sets bench_start to zero. > I cannot distinguish whether we have to fix it, but I attache the patch. > This simply ignores a result when therad->bench_start is zero. > How do you think? 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'm going to give it some thoughts. -- Fabien.