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.89) (envelope-from ) id 1hAjA2-0005Sk-7z for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Mar 2019 22:42:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hAjA0-0006Ru-IP for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Mar 2019 22:42:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAjA0-0006Rl-6F for pgsql-hackers@lists.postgresql.org; Sun, 31 Mar 2019 22:42:40 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAj9x-0000w5-Ac for pgsql-hackers@postgresql.org; Sun, 31 Mar 2019 22:42:38 +0000 Received: by mail-pf1-x444.google.com with SMTP id i17so3561192pfo.6 for ; Sun, 31 Mar 2019 15:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PojxzuxsP7UT6SfV3yhgUXrQaS4D+rAO2U+unCrT69k=; b=VHnICzRrpVaGqnJEBmrUiDdro88DvDY45/zPIKjSW1YmiDfwfmlWh6eFvY2Pu6UdHf txYaEgwQyh3lh0woOYDSp/3aa9tGCXHly2gp1VgYtPJuF4LUrwH8Cl3ZKvRMovif+FDw ecW4KBWzNuvbN9C0AsCw/CbySihuWSXT09Aqk= 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PojxzuxsP7UT6SfV3yhgUXrQaS4D+rAO2U+unCrT69k=; b=JwIvxuhNjRNqIyW0LBykzNvpnaMv8174yWVqHzCeOokZzMsuz3F3Q1KkL2kGzXpnnl Z4ifUfjxH64wGLqJ5jkj/UG66USqm3Jrc5GudFegi6Gk+16D7017+Qj6ilpcFf1MbcfA wrhnTDSoBFohCY2ra56IXQpGhwXE4QruhFZJC+0/lRiK2VYDON5eYmitDCY3Y3A/AABQ muLUZkyZ5rLCB1emPMSR2IoJ85Kuv4HbZhrB0R1vexBSbfyj09FUYbR0MdAC2y/2/WCw Jr7kEDuIYDsOgMTsclLYqXoGtSzs6/HkfCmqoa9EGEE0ZiwF9Z7/V3wluDmvir75PZte 6Hrw== X-Gm-Message-State: APjAAAWmeVsd//54u/+hc6r8ZEM02Hzrcvph8VtePUxZOjifMb4wMe0p AISBQrlCnqswAYlYkrH1eaNgssm3j8Y= X-Google-Smtp-Source: APXvYqxxle5JPa2mYPMGhhfzcxyQ8hbWCis+Jy9XJ5stBqzkVbrwv4Bkie1xi5r4n50iysbZafBe7g== X-Received: by 2002:a63:2aca:: with SMTP id q193mr58181953pgq.269.1554072156198; Sun, 31 Mar 2019 15:42:36 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id i16sm11666006pgk.51.2019.03.31.15.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 15:42:35 -0700 (PDT) Date: Sun, 31 Mar 2019 15:42:33 -0700 From: Noah Misch To: Daniel Gustafsson Cc: Kyotaro HORIGUCHI , "9erthalion6@gmail.com" <9erthalion6@gmail.com>, "sfrost@snowman.net" , "pgsql-hackers@postgresql.org" Subject: Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid Message-ID: <20190331224233.GC891537@rfd.leadboat.com> References: <20181130065140.GB2774301@rfd.leadboat.com> <20181203004106.GA2860387@rfd.leadboat.com> <20190304.180420.139624607.horiguchi.kyotaro@lab.ntt.co.jp> <20190307032422.GB1797215@rfd.leadboat.com> <20190309071610.GA2039121@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Mar 29, 2019 at 09:53:51AM +0000, Daniel Gustafsson wrote: > On Saturday, March 9, 2019 8:16 AM, Noah Misch wrote: > > I renamed IpcMemoryAnalyze() to PGSharedMemoryAttach() and deleted the old > > function of that name. Now, this function never calls shmdt(); the caller is > > responsible for that. I do like things better this way. What do you think? > > I think it makes for a good API for the caller to be responsible, but it does > warrant a comment on the function to explicitly state that. The name "PGSharedMemoryAttach" makes that fact sufficiently obvious, I think. > A few other small comments: > > + state = PGSharedMemoryAttach((IpcMemoryId) id2, &memAddress); > + if (memAddress) > + shmdt(memAddress); > > This seems like a case where it would be useful to log a shmdt() error or do > an Assert() around the success of the operation perhaps? I'll add the same elog(LOG) we have at other shmdt() sites. I can't think of a site where we Assert() about the results of a system call. While shmdt() might be a justified exception, elog(LOG) seems reasonable. > + * Loop till we find a free IPC key. Trust CreateDataDirLockFile() to > + * ensure no more than one postmaster per data directory can enter this > + * loop simultaneously. (CreateDataDirLockFile() does not ensure that, > + * but prefer fixing it over coping here.) > > This comment make it seem like there is a fix to CreateLockFile() missing to > his patch, is that correct? If so, do you have an idea for that patch? That comment refers to https://postgr.es/m/flat/20120803145635.GE9683%40tornado.leadboat.com > Switching this to Ready for Committer since I can't see anything but tiny things. Thanks.