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 1l0IWd-0001ZM-8c for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jan 2021 06:23:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l0IWc-0001DC-0e for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jan 2021 06:23:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0IWb-0001D5-QF for pgsql-hackers@lists.postgresql.org; Fri, 15 Jan 2021 06:23:57 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0IWZ-0004Y8-Gy for pgsql-hackers@postgresql.org; Fri, 15 Jan 2021 06:23:56 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTP id C4A2562825; Fri, 15 Jan 2021 15:23:51 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 15 Jan 2021 15:23:51 +0900 From: torikoshia To: Ian Lawrence Barwick Cc: Robert Haas , Justin Pryzby , pgsql-hackers Subject: Re: adding wait_start column to pg_locks In-Reply-To: References: <20210101214930.GH25152@telsasoft.com> <9e958478d8bcea814e7ce16511a18912@oss.nttdata.com> Message-ID: <23d39ee9c31643fad8f9ba9c5cf3aaf4@oss.nttdata.com> X-Sender: torikoshia@oss.nttdata.com User-Agent: Roundcube Webmail/1.1.9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thanks for your reviewing and comments! On 2021-01-14 12:39, Ian Lawrence Barwick wrote: > Looking at the code, this happens as the wait start time is being > recorded in > the lock record itself, so always contains the value reported by the > latest lock > acquisition attempt. I think you are right and wait_start should not be recorded in the LOCK. On 2021-01-15 11:48, Ian Lawrence Barwick wrote: > 2021年1月15日(金) 3:45 Robert Haas : > >> On Wed, Jan 13, 2021 at 10:40 PM Ian Lawrence Barwick >> wrote: >>> It looks like the logical place to store the value is in the >> PROCLOCK >>> structure; ... >> >> That seems surprising, because there's one PROCLOCK for every >> combination of a process and a lock. But, a process can't be waiting >> for more than one lock at the same time, because once it starts >> waiting to acquire the first one, it can't do anything else, and >> thus >> can't begin waiting for a second one. So I would have thought that >> this would be recorded in the PROC. > > Umm, I think we're at cross-purposes here. The suggestion is to note > the time when the process started waiting for the lock in the > process's > PROCLOCK, rather than in the lock itself (which in the original > version > of the patch resulted in all processes with an interest in the lock > appearing > to have been waiting to acquire it since the time a lock acquisition > was most recently attempted). AFAIU, it seems possible to record wait_start in the PROCLOCK but redundant since each process can wait at most one lock. To confirm my understanding, I'm going to make another patch that records wait_start in the PGPROC. Regards, -- Atsushi Torikoshi