Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdI6M-00066H-P3 for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Nov 2013 11:13:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VdI6M-0002nH-3d for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Nov 2013 11:13:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdI6L-0002lb-80 for pgsql-hackers@postgresql.org; Mon, 04 Nov 2013 11:13:45 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdI6B-0003rp-4h for pgsql-hackers@postgresql.org; Mon, 04 Nov 2013 11:13:43 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 6BA3A29841; Mon, 4 Nov 2013 03:13:31 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 631851858B; Mon, 4 Nov 2013 03:13:31 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id B3E8612002F; Mon, 4 Nov 2013 03:20:37 -0800 (PST) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Mon, 4 Nov 2013 03:20:36 -0800 (PST) Message-ID: <52778157.9050907@vmware.com> Date: Mon, 04 Nov 2013 13:13:27 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: Andres Freund CC: Noah Misch , Robert Haas , Tom Lane , Andrew Dunstan , "pgsql-hackers@postgresql.org" Subject: Re: Something fishy happening on frogmouth References: <527223E8.2020207@vmware.com> <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> In-Reply-To: <20131104095521.GI3567@awork2.anarazel.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.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 04.11.2013 11:55, Andres Freund wrote: > On 2013-11-04 10:27:47 +0200, Heikki Linnakangas wrote: >> Hmm, here's another idea: >> >> 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. > 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." 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. > I think this is looking for a solution without an actually relevant > problem disregarding the actual problem space. I agree. What are these dynamic shared memory segments supposed to be used for? - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers