BUG #17368: Assert failed in GetSafeSnapshot() for SERIALIZABLE READ ONLY DEFERRABLE transaction

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #17368: Assert failed in GetSafeSnapshot() for SERIALIZABLE READ ONLY DEFERRABLE transaction
Date: 2022-01-15 08:00:01
Message-ID: 17368-98a4f99e8e4b4402@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17368
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 14.1
Operating system: Ubuntu 20.04
Description:

The isolation test "read-only-anomaly-3" modified as follows:
setup
{
CREATE TABLE bank_account (id TEXT PRIMARY KEY, balance DECIMAL NOT
NULL);
INSERT INTO bank_account (id, balance) VALUES ('X', 0), ('Y', 0);
}

teardown
{
DROP TABLE bank_account;
}

session s1
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; }
step s1ry { SELECT balance FROM bank_account WHERE id = 'Y'; }
step s1wy { UPDATE bank_account SET balance = 20 WHERE id = 'Y'; }
step s1c { COMMIT; }

session s2
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; }
step s2rx { SELECT balance FROM bank_account WHERE id = 'X'; }
step s2ry { SELECT balance FROM bank_account WHERE id = 'Y'; }
step s2wx { UPDATE bank_account SET balance = -11 WHERE id = 'X'; }
step s2c { COMMIT; }

session s3
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY
DEFERRABLE; }
step s3r { SELECT id, balance FROM bank_account WHERE id IN ('X', 'Y') ORDER
BY id; }
step s3c { COMMIT; }

session s4
setup { BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; }
step s4to { SET lock_timeout = '10ms' }
step s4wx { UPDATE bank_account SET balance = -11 WHERE id = 'X'; }
step s4c { COMMIT; }

permutation s2rx s2ry s1ry s1wy s1c s3r s2wx s2c s3c
permutation s2ry s1wy s1c s2wx s4to s4wx s4c s3r s2c s3c

causes an assertion failure with the following stacktrace:
Core was generated by `postgres: law isolation_regression [local] SELECT
'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007f53a8a7c859 in __GI_abort () at abort.c:79
#2 0x000055edb1e89381 in ExceptionalCondition (conditionName=0x55edb2832980
"SxactIsROSafe(MySerializableXact)",
errorType=0x55edb2831da0 "FailedAssertion", fileName=0x55edb2831d60
"predicate.c", lineNumber=1612) at assert.c:69
#3 0x000055edb1714442 in GetSafeSnapshot (origSnapshot=0x55edb6ac6e40
<CurrentSnapshotData>) at predicate.c:1612
#4 0x000055edb1714b91 in GetSerializableTransactionSnapshot
(snapshot=0x55edb6ac6e40 <CurrentSnapshotData>)
at predicate.c:1703
#5 0x000055edb201d623 in GetTransactionSnapshot () at snapmgr.c:291
#6 0x000055edb17613b5 in exec_simple_query (
query_string=0x625000005220 "SELECT id, balance FROM bank_account WHERE
id IN ('X', 'Y') ORDER BY id;")
at postgres.c:1103
#7 0x000055edb176ea2e in PostgresMain (argc=1, argv=0x7ffdfa7290d0,
dbname=<optimized out>,
username=0x629000011258 "law") at postgres.c:4486
#8 0x000055edb13ea951 in BackendRun (port=0x615000004900) at
postmaster.c:4530
#9 0x000055edb13e9142 in BackendStartup (port=0x615000004900) at
postmaster.c:4252
#10 0x000055edb13df0a3 in ServerLoop () at postmaster.c:1745
#11 0x000055edb13dcf20 in PostmasterMain (argc=8, argv=0x607000000170) at
postmaster.c:1417
#12 0x000055edb0f075c3 in main (argc=8, argv=0x607000000170) at main.c:209

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2022-01-15 16:00:00 Re: BUG #17368: Assert failed in GetSafeSnapshot() for SERIALIZABLE READ ONLY DEFERRABLE transaction
Previous Message Thomas Munro 2022-01-15 05:41:42 Re: BUG #17116: Assert failed in SerialSetActiveSerXmin() on commit of parallelized serializable transaction