From: Kevin Grittner <kgrittn@ymail.com>
To: Marko Tiikkaja <marko@joh.to>
To: kop@meme.com <kop@meme.com>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12469: pg_locks shows locks held by pids not found i n pg_stat_activity or ps
Date: Fri, 9 Jan 2015 19:09:31 +0000 (UTC)
Message-ID: <459679274.4229417.1420830571464.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com> (raw)
In-Reply-To: <54B0218C.6080808@joh.to>
References: <54B0218C.6080808@joh.to>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Marko Tiikkaja <marko@joh.to> wrote:
> On 2015-01-09 19:07, Kevin Grittner wrote:
>> "kop@meme.com" <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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: kgrittn@ymail.com, marko@joh.to, kop@meme.com
Subject: Re: BUG #12469: pg_locks shows locks held by pids not found i n pg_stat_activity or ps
In-Reply-To: <459679274.4229417.1420830571464.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com>
References: <54B0218C.6080808@joh.to> <459679274.4229417.1420830571464.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox