From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Radoslav Nedyalkov <rnedyalkov(at)gmail(dot)com> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: is pg_advisory_lock() suitable for long runs |
Date: | 2018-04-03 16:30:07 |
Message-ID: | CAHyXU0yK-Vc2hB+5Y6-m4Wy8JBeRz5DsZOo7zBP-8dW1V7ae=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, Mar 31, 2018 at 1:49 PM, Radoslav Nedyalkov
<rnedyalkov(at)gmail(dot)com> wrote:
> Hi all,
> it's very simple and intuitive case but let me describe first.
> 1. session 1 calls pg_advisory_lock(1234) and succeeds.
> 2. session 2 calls pg_advisory_lock(1234) and stops on waiting.
> All fine BUT pid for session2 appears already with backend_xmin in
> pg_stat_activity
> which means vacuum won't be able to remove rows younger than session2
> backend_xmin.
>
> Well, we planned to use pg_advisory_lock() as a boot phase in a hot-standby
> appserver
> and apparently this will be problematic as the session2 might wait for
> weeks.
>
> Any thoughts ? Do we miss something ?
Holding a transaction open for weeks is generally not a good idea, at
all. Advisory locks were invented very specifically to allow
application locks to be held without involving long running
transactions. Holding a session open for weeks might be ok, but any
blocked lockers ought to time out and try another course of action.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | hmidi slim | 2018-04-03 16:40:28 | Re: How to get an inclusive interval when using daterange |
Previous Message | Ranjith Ramachandra | 2018-04-03 15:22:31 | Re: Seems like there is an issue with reltuples showing twice the number of rows |