Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHqzv-0003HD-4l for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2020 15:34:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHqzt-000358-My for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2020 15:34:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHqzt-000351-Dw for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2020 15:34:13 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jHqzq-0004d3-D9 for pgsql-hackers@postgresql.org; Fri, 27 Mar 2020 15:34:13 +0000 Received: by mail-pg1-x542.google.com with SMTP id b1so4726799pgm.8 for ; Fri, 27 Mar 2020 08:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=KJtn98thCwsUogkkrezNIQwo87fOTWsEZK7CwFbYVF4=; b=e8DmHKqLrAIcrGQVAjm+VRyD2173dUZKrJLi+8KaEUmJR6nVfTNSWkwT2ywa70rTkQ ldXLiqO/xyNQigS5x5vzwHFZJytilGP+G9asAasWg/Bg04dd4sVTQSLrpoKiH3/WO+Wa vxNg8x7/bjYyNzUpthwWAm0kdsJngm1DbEG9bPIfG7cLPN4icrU0wma9XlR6FoprrrMZ 1fwLgVhnz8rK3oyvy7B3+POYrSQWi61RGF/0trsT0AEoAiHxb4H5++UZWPIDT+cnMjYx bZ6Dpxrp457xJeOo7Z4/znNpRQKkl8vTdCchzlIvd4jsnpF3nTrr6loc7ADNP1gq4njW NIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=KJtn98thCwsUogkkrezNIQwo87fOTWsEZK7CwFbYVF4=; b=AlKxgb4uRGZvhG2g3k4unDXhwFVVvqLweJiOmtMzyJIfQRcL3M1tKOku8Dbqz/U3I9 +YfH9vj1BeYct/FKyLrN5d7h8cAEK/TRNLbHRTfP+982FSSF1y743VwqcqXRBsY0+TYX +SNqX9SzUORvujIxcu1XM+NuE7VONQ2D17ZyQrfmWMVhU3nlfJlDda+cYe+UAvjpDQvN JLFXHMRVW7OQODuxhDdxgnhJYzHvHQkG7KMuUNmMCDma1xtVhPfdUfg9S74FLvsRjSxs xAMNyOkvlFT8qaAyylhyGCXYv4e//vXC+6DDKtiY8GurS880hDJC5mfnxbDYqpLna5BI agkQ== X-Gm-Message-State: ANhLgQ3E5fn7ceyW9oEr1PbG8L9KFaBOPK5fOOVzUWhXMb0Cv1F8OX1X bsA/G0NA/qJD3fQLDrE1dqFByg== X-Google-Smtp-Source: ADFU+vuR56joHJE3UNieFSAuPwn14DVLQyBAatGr5K4UIIYZxeY1GThi29C3O0EQ628wHckmR19+5g== X-Received: by 2002:a63:8b41:: with SMTP id j62mr13960642pge.18.1585323248260; Fri, 27 Mar 2020 08:34:08 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([174.128.226.18]) by smtp.gmail.com with ESMTPSA id bo12sm3985622pjb.16.2020.03.27.08.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 08:34:07 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 3F6AF30093A; Fri, 27 Mar 2020 12:34:02 -0300 (-03) Date: Fri, 27 Mar 2020 12:34:02 -0300 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: andres@anarazel.de, michael@paquier.xyz, thomas.munro@gmail.com, tomas.vondra@2ndquadrant.com, a.zakirov@postgrespro.ru, ah@cybertec.at, magnus@hagander.net, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org Subject: Re: shared-memory based stats collector Message-ID: <20200327153402.GA1045@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200327.163115.1814716981588442968.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Mar-27, Kyotaro Horiguchi wrote: > +/* > + * XLogArchiveWakeupEnd - Set up archiver wakeup stuff > + */ > +void > +XLogArchiveWakeupStart(void) > +{ > + Latch *old_latch PG_USED_FOR_ASSERTS_ONLY; > + > + SpinLockAcquire(&XLogCtl->info_lck); > + old_latch = XLogCtl->archiverWakeupLatch; > + XLogCtl->archiverWakeupLatch = MyLatch; > + SpinLockRelease(&XLogCtl->info_lck); > + Assert (old_latch == NULL); > +} Comment is wrong about the function name; OTOH I don't think the old_latch assigment in the fourth line won't work well in non-assert builds. But why do you need those shenanigans? Surely "Assert(XLogCtl->archiverWakeupLatch == NULL)" in the locked region before assigning MyLatch should be sufficient and acceptable? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services