pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix race in SERIALIZABLE READ ONLY.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:32  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:32 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/65e388d4182ae4eba5afe880471453d33a4097d8

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:32  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:32 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
REL_15_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:32  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:32 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:32  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:32 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
REL_13_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:33  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
REL_12_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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

* pgsql: Fix race in SERIALIZABLE READ ONLY.
@ 2023-03-09 04:33  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2023-03-09 04:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix race in SERIALIZABLE READ ONLY.

Commit bdaabb9b started skipping doomed transactions when building the
list of possible conflicts for SERIALIZABLE READ ONLY.  That makes
sense, because doomed transactions won't commit, but a couple of subtle
things broke:

1.  If all uncommitted r/w transactions are doomed, a READ ONLY
transaction would arbitrarily not benefit from the safe snapshot
optimization.  It would not be taken immediately, and yet no other
transaction would set SXACT_FLAG_RO_SAFE later.

2.  In the same circumstances but with DEFERRABLE, GetSafeSnapshot()
would correctly exit its wait loop without sleeping and then take the
optimization in non-assert builds, but assert builds would fail a sanity
check that SXACT_FLAG_RO_SAFE had been set by another transaction.

This is similar to the case for PredXact->WritableSxactCount == 0.  We
should opt out immediately if our possibleUnsafeConflicts list is empty
after filtering.

The code to maintain the serializable global xmin is moved down below
the new opt out site, because otherwise we'd have to reverse its effects
before returning.

Back-patch to all supported releases.  Bug #17368.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/17116-d6ca217acc180e30%40postgresql.org
Discussion: https://postgr.es/m/20110707212159.GF76634%40csail.mit.edu

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 49 +++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)



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


end of thread, other threads:[~2023-03-09 04:33 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 04:32 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>
2023-03-09 04:32 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>
2023-03-09 04:32 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>
2023-03-09 04:32 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>
2023-03-09 04:33 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>
2023-03-09 04:33 pgsql: Fix race in SERIALIZABLE READ ONLY. Thomas Munro <tmunro@postgresql.org>

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