pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: me@jix.one
To: pgsql-docs@lists.postgresql.org
Subject: Re: Warn against transaction level advisory locks for emulating "flat file" DBMS locking strategies
Date: Wed, 08 Sep 2021 18:26:12 +0200
Message-ID: <f369dc4469030e51c3afd661a49846cb3e6afcc9.camel@cybertec.at> (raw)
In-Reply-To: <163108943900.696.7027791431029866787@wrigleys.postgresql.org>
References: <163108943900.696.7027791431029866787@wrigleys.postgresql.org>

On Wed, 2021-09-08 at 08:23 +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/13/explicit-locking.html
> Description:
> 
> The docs mention "For example, a common use of advisory locks is to emulate
> pessimistic locking strategies typical of so-called “flat file” data
> management systems" which is exactly what I wanted to use to port some code
> from using SQLite to using PostgreSQL. (The code in question requires
> serializable transactions and cannot not handle retries.)
> 
> The next paragraph explains session and transaction level advisory locks and
> mentions that transaction level locks are "often more convenient than the
> session-level behavior". This seemed to be true for this use case, so I
> chose to use them.
> 
> Later I discovered that obtaining a transaction level lock as first
> statement _within_ a transaction is not sufficient to emulate global
> pessimistic locking and can occasionally still result in serialization
> failures.

I don't see how that is related to session-level vs. transaction level locks.

erhaps you can explain your case in some more detail.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (4+ messages)  latest in thread

Message-ID: <f369dc4469030e51c3afd661a49846cb3e6afcc9.camel@cybertec.at>
Permalink:  ../f369dc4469030e51c3afd661a49846cb3e6afcc9.camel@cybertec.at/
Also on:    postgresql.org/message-id/f369dc4469030e51c3afd661a49846cb3e6afcc9.camel@cybertec.at

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: laurenz.albe@cybertec.at, me@jix.one, pgsql-docs@lists.postgresql.org
  Subject: Re: Warn against transaction level advisory locks for emulating "flat file" DBMS locking strategies
  In-Reply-To: <f369dc4469030e51c3afd661a49846cb3e6afcc9.camel@cybertec.at>

* 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