pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix check for conflicting session- vs transaction-level locks.
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6310809c4aa146b3996a35524955c6c6943d241a

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/712ba6b8b73870fa9e3336df8d88f4bc5f824112

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f47408cdc19c2bbe357703afd81037b6d12ed3ba

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/899785b4f6c8c732c233e23c31a93405cff5ec34

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7b2262a21cde4e943cf220e201ace3f61623bdfe

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/654372169b8935ef1a4233522d711fe5e556e280

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix check for conflicting session- vs transaction-level locks.
@ 2021-07-24 22:36 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2021-07-24 22:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix check for conflicting session- vs transaction-level locks.

We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1861390e6cf52bd36e100a64bfc5449dd82377fb

Modified Files
--------------
src/backend/storage/lmgr/lock.c                | 129 ++++++++++++++++++++-----
src/test/regress/expected/prepared_xacts.out   |  16 +++
src/test/regress/expected/prepared_xacts_1.out |  17 ++++
src/test/regress/sql/prepared_xacts.sql        |   6 ++
4 files changed, 144 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2021-07-24 22:36 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>
2021-07-24 22:36 pgsql: Fix check for conflicting session- vs transaction-level locks. Tom Lane <tgl@sss.pgh.pa.us>

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