Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdIBm-0006a4-Uf for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Nov 2013 11:19:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VdIBm-0004FA-D3 for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Nov 2013 11:19:22 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdIBl-0004F2-EU for pgsql-hackers@postgresql.org; Mon, 04 Nov 2013 11:19:21 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdIBi-0000nV-0Z for pgsql-hackers@postgresql.org; Mon, 04 Nov 2013 11:19:20 +0000 Received: from anarazel.de (p5DDC6D42.dip0.t-ipconnect.de [93.220.109.66]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MFVyq-1VP35x2VaG-00EYwg; Mon, 04 Nov 2013 12:19:13 +0100 Received: by anarazel.de (Postfix, from userid 1000) id EFB78100AA1; Mon, 4 Nov 2013 12:19:12 +0100 (CET) Date: Mon, 4 Nov 2013 12:19:12 +0100 From: Andres Freund To: Heikki Linnakangas Cc: Noah Misch , Robert Haas , Tom Lane , Andrew Dunstan , "pgsql-hackers@postgresql.org" Subject: Re: Something fishy happening on frogmouth Message-ID: <20131104111912.GD17233@awork2.anarazel.de> References: <20131031095021.GA31628@alap2.anarazel.de> <22875.1383229757@sss.pgh.pa.us> <5272EC6A.2020004@vmware.com> <20131101162230.GA649568@tornado.leadboat.com> <52775A83.7090206@vmware.com> <20131104095521.GI3567@awork2.anarazel.de> <52778157.9050907@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52778157.9050907@vmware.com> X-Provags-ID: V02:K0:JvgWpYwQeRttNnQHwRzHARPcd0bI06haJX9O1+GiMdb E5iq5984A10hM8GjR7PcPw/zeXq/pz2GUYHdwwUvC9KgkQtBsZ 9EIoX5WYnWzbVm8DwCTbzrfZ3HkUSyDL/XMWDBdFm6S6jzNqoJ +gHoawyruIG8X658jQtfvtaFL1QgyhZqHbhyUymoDxUTHDCA0F 23PkLCYw1u9c3ur8Nssk7mR10Lvv3l96h3hKY/e1qg0ek9Txyn L/ejtE9/Yb4XAXSlls1f4I469Z3MfX4t2MOI58zQfVfY6KVbAQ FInXmY8J2YXI/Gt7K64TO6mzbOdyZZj401UeEfJ3FgV0SxNUAf Th8taCRrGVANC2gbBac9ExtftVXVKUVXmjcVmmqxr X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2013-11-04 13:13:27 +0200, Heikki Linnakangas wrote: > On 04.11.2013 11:55, Andres Freund wrote: > >On 2013-11-04 10:27:47 +0200, Heikki Linnakangas wrote: > >>Postmaster creates the POSIX shared memory object at startup, by calling > >>shm_open(), and immediately calls shm_unlink on it. That way, once all the > >>processes have exited, the object will be removed automatically. Child > >>processes inherit the file descriptor at fork(), and don't need to call > >>shm_open, just mmap(). > > > >Uh. Won't that completely and utterly remove the point of dsm which is > >that you can create segments *after* startup? We surely don't want to > >start overallocating enough shmem so we don't ever dynamically need to > >allocate segments. > You don't need to allocate the shared memory beforehand, only create the > file descriptor. Note that the size of the segment is specified in the > shm_open() call, but the mmap() that comes later. > > If we need a large amount of small segments, so that it's not feasible to > shm_open() them all at postmaster startup, you could shm_open() just one > segment, and carve out smaller segments from it by mmap()ing at different > offsets. That quickly will result in fragmentation which we don't have the tools to handle. > >Also, I don't think it's portable across platforms to access segments > >that already have been unlinked. > > See > http://pubs.opengroup.org/onlinepubs/009695299/functions/shm_unlink.html: > "If one or more references to the shared memory object exist when the object > is unlinked, the name shall be removed before shm_unlink() returns, but the > removal of the memory object contents shall be postponed until all open and > map references to the shared memory object have been removed." We also support sysv shmem and have the same cleanup problem there. > That doesn't explicitly say that a new shm_open() on the file descriptor > must still work after shm_unlink, but I would be surprised if there is a > platform where it doesn't. Probably true. > >I think this is looking for a solution without an actually relevant > >problem disregarding the actual problem space. To make that clearer: I think the discussions about making it impossible to leak segments after rm -rf are the irrelevant problem. > I agree. What are these dynamic shared memory segments supposed to be used > for? Parallel sort and stuff like that. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers