Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9ewT-0008TT-ED for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Jan 2015 19:09:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y9ewS-0000Me-UF for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Jan 2015 19:09:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y9ewR-0000KN-BD for pgsql-bugs@postgresql.org; Fri, 09 Jan 2015 19:09:51 +0000 Received: from nm18-vm3.bullet.mail.ne1.yahoo.com ([98.138.91.148]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y9ewM-0004gg-S5 for pgsql-bugs@postgresql.org; Fri, 09 Jan 2015 19:09:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1420830583; bh=g8ble9954/xY2a28Naq2/9mKWSrmMjTSMSFeS4ICACI=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=sbh+lOCwYZExlfQlC6tXvdVzSnEPjKkZb8rQDH8+5QnYWJZh6OI4qjbpmfx9EvTWhfuCdNDvGgLRKI8xX+Dg8b2vUN/nUTCW0e80ZJOA7l+jigcy6761EVXjnUUfBB8W3Jpho49Jtfm7kzpuyipegRraDOC5G8NCps7fAkfXJolcwQOmn1sCtONpYzRtnQt+1NhZrX5BrU++6RVOcos3hb6LWn3LECnIzh1vKsAiIC0mtGP54OpRSJFvqcKwkkDgOHc567VFFHACNJPM7xyO+Dq+mBTL5H8Webx/g1NbX7UduvrlctRBhqfPRh7rpdspSqs4SpZlMdxJMEoajblTcA== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=ymail.com; b=rrFhSxh36rxclXFYmwsHydqWbipDrnyC/UmRArUHMO+69TJcqNYkxnsxXWXIHS9gywT5oNB2urMkvi4nhkfBjwav3A7l4C06N3uxAfq0/kzbmsDWGk9y1a5CpQUZ7Eg4YJFZmgMmK1v6DuTW9xXozAjG1+s+ccrhaeomr55HQx1QM7BOZZ+cxl2I4sr1+XSLCw5UittD+DPzfFO/+q238lb7d8FOYZlPD/1SJgixlVxxfhN7sy9oFfct3QLJeOzhSPquY3+Kg+3+SP1AYoUZPti1ee9nkT4maMKQd8NN3rQUel2VBBKxuVq6G216RYm8Wrc2GlwDc2LAO3lyBBTU5g==; Received: from [98.138.100.113] by nm18.bullet.mail.ne1.yahoo.com with NNFMP; 09 Jan 2015 19:09:43 -0000 Received: from [98.138.226.169] by tm104.bullet.mail.ne1.yahoo.com with NNFMP; 09 Jan 2015 19:09:43 -0000 Received: from [127.0.0.1] by omp1070.mail.ne1.yahoo.com with NNFMP; 09 Jan 2015 19:09:43 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 350796.52247.bm@omp1070.mail.ne1.yahoo.com X-YMail-OSG: _zBCTbAVM1lEmhDNn_SAOkkelh1cRxFUcWdv2XOtcqCeI7w64mkkJJJnHrKy.Pe G8UbBY1Luc1Kq.v93.CdLtcMu8spLm9xedLx1eJFl8dDGaGog.yFviylAIVKPRMw4GUkUlBqueYZ zGSTb187rSFXeY_osSW1a9bsZ9sMOzAdOrx_fNC8.D2pPYK3KfVb97mt8bnLjNGQHeIKB45mK60d uANYReBP6f.wbDjaCzg57VaEn94J2GY8DmzK0.qevdTuTLsTqK5q1ZWGgDsSQX50qqb4Is3sXtkC weiM3b1d0OVZYgFqRtX1MF_Dd3a5yPH8RRhauiUXJhq3oSdi.wJs72.ewD_INLWdZJX4YkoFw8.D c5vdxeMaZVD7RhwEEItsXb9znbedrZjx9hwOEtk59sO2d70CYkLHKrneN3KEDXgC36Sto8VJBkPl 3gxN5RReBZEvNia22gJXR9VVYr2RBDhdiiqRUyuT44Q_kf.enK6UquhVPjB3B6OT9KAJS20lc82n LUIv.0hCgos8Rvsu8jnZTcqG9ooKdb.jKkHxJ5DDZn4RYPuAB8xHZBw-- Received: by 98.138.101.169; Fri, 09 Jan 2015 19:09:42 +0000 Date: Fri, 9 Jan 2015 19:09:31 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: Marko Tiikkaja , "kop@meme.com" , "pgsql-bugs@postgresql.org" Message-ID: <459679274.4229417.1420830571464.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com> In-Reply-To: <54B0218C.6080808@joh.to> References: <54B0218C.6080808@joh.to> Subject: Re: BUG #12469: pg_locks shows locks held by pids not found i n pg_stat_activity or ps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 2058 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Marko Tiikkaja wrote: > On 2015-01-09 19:07, Kevin Grittner wrote: >> "kop@meme.com" wrote: >>> I found that after running a large transaction (for days, it's still >>> running) and then running out of shared memory that pg_locks reports locks >>> held by pids that do not seem to exist, either in ps output or in >>> pg_stat_activity. >> >> That is not a bug. > > I find that really surprising. What if the pid gets reused and you have > entries in pg_locks with the pid that aren't actually held by that > backend? That's enough to drive anyone having to debug that mess insane. > > Can we not clear the pids or something, at least at backend exit? Indeed we could. There was some discussion of whether it would be better to leave the pid in pg_locks so it could be matched up against log entries which led up to the lock, or whether it should be removed in case it lasted long enough to survive PID wrap-around and thereby possibly confuse someone looking at the lock information. (It is just an "informational" column, not one used to manage the serializable logic, so its presence or absence doesn't affect the correctness of serializable behavior.) The argument that it was more useful to leave it there than to remove it held sway. It would be trivial to remove it on commit, but that would eliminate its usefulness where there isn't any possibility of ambiguity. To remove it on connection close would require scanning a list for matches, so I think it would add an O(N^2) performance hit to closing a connection. I guess the question is whether PID wraparound occurs while a single database transaction is open often enough to make it worthwhile add that overhead. Also keep in mind that there might still be server logs with the pid which could usefully be matched against this value, even after PID wraparound -- it's just that if the same pid had been reused for a new connection you would have an ambiguous reference. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs