From owner-freebsd-stable@FreeBSD.ORG Mon Apr 3 17:27:11 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4CB6616A400; Mon, 3 Apr 2006 17:27:11 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id A898B43D75; Mon, 3 Apr 2006 17:27:08 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 22A9046BE0; Mon, 3 Apr 2006 13:27:07 -0400 (EDT) Date: Mon, 3 Apr 2006 18:27:07 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: "Marc G. Fournier" In-Reply-To: <20060403140902.C947@ganymede.hub.org> Message-ID: <20060403182504.S76562@fledge.watson.org> References: <20060403140902.C947@ganymede.hub.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Daniel Eischen , freebsd-stable@freebsd.org, Andrew Thompson , Kris Kennaway Subject: Re: [HACKERS] semaphore usage "port based"? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Apr 2006 17:27:11 -0000 On Mon, 3 Apr 2006, Marc G. Fournier wrote: > The problem is that PostgreSQL uses kill(PID, 0) to determine whether or not > another process is running when it tries to allocate a semaphore ... > > for instance, when it starts up, it tries to semget(54320001); ... if that > fails, based on the PID that is attached to that semaphore, it tries to do a > kill(PID,0) ... if that fails, it then *takes over* that semaphore ... under > 4.x, kill(PID,0) *would* return that a process is running, even if it was in > another jail, altho the jail issuing the kill can't see that process, so > postgresql would go on to 54320002, and test that ... under FreeBSD 6.x, > kill(PID, 0) reports "not in use", so PostgreSQL stomps on that semaphore > ... Robert brought up a good point, about recycled PIDs, but Tom Lane's > response to that about the fact that we don't care if the process that is > running is the one *actually* holding the semaphore, we'd rather err on the > side of caution and just move on ... but we need to *know* that we need to > move on ... > > We don't need any more information about that process ID then that it is > "currently in use" ... nd I think that is where Andrew was coming from with > issueing EPERM rather then ESRCH ... The problem here is actually that two postgres instances are trying to use the same sempahore when they are actually different postgres instances. One of the postgres instances needs to be configured to use a different semaphore, since they can't share the semaphore. In the event we get virtualization of System V IPC, they can use the same semaphore ID to get different semaphores, but as long as the same ID points to the same sempahore for different instances, it's not going to work. As things stand, if you configure two different instances in two different jails, you need to use the same method you'd use to configure two different instances on the same UNIX host without jails. Does PGSQL have a way to specify the semaphore ID to use? Robert N M Watson