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 1lKEtY-0005Ad-8u for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Mar 2021 06:34:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lKEtX-0004Bk-7X for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Mar 2021 06:34:03 +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 1lKEtX-0004Bd-0b for pgsql-hackers@lists.postgresql.org; Thu, 11 Mar 2021 06:34:03 +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 1lKEtQ-0002bZ-Ac for pgsql-hackers@lists.postgresql.org; Thu, 11 Mar 2021 06:34:02 +0000 Received: from hnk.local (p1439104-ipngn8101funabasi.chiba.ocn.ne.jp [180.0.143.104]) by oss.nttdata.com (Postfix) with ESMTPSA id 7FEFA625C2; Thu, 11 Mar 2021 15:33:52 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: shared-memory based stats collector To: Kyotaro Horiguchi , andres@anarazel.de Cc: gkokolatos@protonmail.com, pgsql-hackers@lists.postgresql.org References: <20210310.175137.77410390117009989.horikyota.ntt@gmail.com> <2f3ce712-0756-8584-6a3f-9c6fe5c43dfa@oss.nttdata.com> <20210311032100.sy25nnjowg7jjf5a@alap3.anarazel.de> <20210311.134227.1280084378060460266.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: <9375d512-2c99-d951-a424-89c813b4df06@oss.nttdata.com> Date: Thu, 11 Mar 2021 15:33:52 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210311.134227.1280084378060460266.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/03/11 13:42, Kyotaro Horiguchi wrote: > At Wed, 10 Mar 2021 19:21:00 -0800, Andres Freund wrote in >> Hi, >> >> Two minor nits: > > Thanks for the comments! > >> On 2021-03-10 21:47:51 +0900, Fujii Masao wrote: >>> +/* Shared memory area for archiver process */ >>> +typedef struct PgArchData >>> +{ >>> + Latch *latch; /* latch to wake the archiver up */ >>> + slock_t mutex; /* locks this struct */ >>> +} PgArchData; >>> + >> >> It doesn't really matter, but it'd be pretty trivial to avoid needing a >> spinlock for this kind of thing. Just store the pgprocno of the archiver >> in PgArchData. > > Looks promising. You mean that spinlock is not necessary by doing the followings? - Save pgprocno of archiver in PgArchData, instead of latch and mutex. - Set PgArch->pgprocno at the startup of archiver - Reset PgArch->pgprocno to INVALID_PGPROCNO at pgarch_die() - XLogArchiveNotify() sets the latch (i.e., &ProcGlobal->allProcs[PgArch->pgprocno].procLatch) if PgArch->pgprocno is not INVALID_PGPROCNO Right? > >> While getting rid of the spinlock doesn't seem like a huge win, it does >> seem nicer that we'd automatically have a way to find data about the >> archiver (e.g. pid). > > PGPROC GetAuxProcessInfo(AuxProcType type)? I don't think this new function is necessary. ISTM that Andres said that it's worth adding pgprocno into PgArch because which enables us to get the information about archiver more easily by using that pgprocno. For example, we can get the pid of archiver by &ProcGlobal->allProcs[PgArch->pgprocno].pid. That is, he thinks that adding pgprocno has several merits. I agree that. Maybe I'm misunderstanding his comment, though... > >>> * checkpointer to exit as well, otherwise not. The archiver, stats, >>> * and syslogger processes are disregarded since they are not >>> * connected to shared memory; we also disregard dead_end children >>> * here. Walsenders are also disregarded, they will be terminated >>> * later after writing the checkpoint record, like the archiver >>> * process. >>> */ >> >> This comment in PostmasterStateMachine() is outdated now. > > Right. Will fix a bit later. Thanks! Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION