Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Serializable isolation SELECT, DELETE, SELECT inconsistency for PK #2831

Closed
jaki opened this issue Nov 4, 2019 · 1 comment
Closed
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug

Comments

@jaki
Copy link
Contributor

jaki commented Nov 4, 2019

There is a somewhat specific circumstance that causes a serializable isolation transaction to break serializability.

Session A Session B
CREATE TABLE t (i int PRIMARY KEY)
INSERT INTO t VALUES (1), (2), (3)
BEGIN ISOLATION LEVEL SERIALIZABLE
<stmt>
DELETE FROM t WHERE i = 2
<stmt>
COMMIT
<stmt> PostgreSQL 11 Yugabyte
SELECT * FROM t 3 rows; 3 rows 3 rows; 2 rows
SELECT i FROM t WHERE i = 1 1 row; 1 row 1 row; 1 row
SELECT i FROM t WHERE i = 2 1 row; 1 row 1 row; fail
SELECT i FROM t WHERE i > 1 2 rows; 2 rows 2 rows; 1 row
SELECT i FROM t 3 rows; 3 rows 3 rows; 2 rows

The failure in the one case above is of the following form:

ERROR:  Operation failed. Try again.: Transaction aborted: 3740fc3e-704a-42f0-9dd8-79606e282a2f

The rest of the cases (except the second) are phantom reads, a violation to serializability.

Changing the table schema to be (i int) makes things behave as in issue #2698. Changing the table schema to be (i int PRIMARY KEY, j int) makes no difference.

Related: #2823.

@jaki jaki added kind/bug This issue is a bug area/ysql Yugabyte SQL (YSQL) labels Nov 4, 2019
@jaki jaki self-assigned this Nov 4, 2019
@jaki
Copy link
Contributor Author

jaki commented Nov 12, 2019

Closed by commit 385d2c5. The behavior is now as follows:

<stmt> PostgreSQL 11 Yugabyte
SELECT * FROM t 3 rows; 3 rows 3 rows; fail
SELECT i FROM t WHERE i = 1 1 row; 1 row 1 row; 1 row
SELECT i FROM t WHERE i = 2 1 row; 1 row 1 row; fail
SELECT i FROM t WHERE i > 1 2 rows; 2 rows 2 rows; fail
SELECT i FROM t 3 rows; 3 rows 3 rows; fail

This is expected behavior for Yugabyte serializable isolation transactions, even though it differs from vanilla PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug
Projects
None yet
Development

No branches or pull requests

1 participant