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] Serializability definition violation #17020

Closed
1 task done
wengsy150943 opened this issue Apr 25, 2023 · 2 comments
Closed
1 task done

[YSQL] Serializability definition violation #17020

wengsy150943 opened this issue Apr 25, 2023 · 2 comments
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/high High Priority

Comments

@wengsy150943
Copy link

wengsy150943 commented Apr 25, 2023

Jira Link: DB-6333

Description

When runing a workload on the lasted version of YugabyteDB, we finds that a query violates the definition of Serializability isolation levels.
We have run the same workload on PostgreSQL, the violation does not happen.
More specifically, as shown in the following table, the workload first launches a serializable transaction (ID=0) to query the record (k=62).
Next, the workload launches another serializable ransaction (ID=19) to modify the record (k=3) and commit.
Finally, the transaction (ID=0) queries the record (k=3).
The expect query result is the transaction (ID=0) fetches the version before it began (k=3), that is the initial version(v=28703).
However, the acctual query result is 15574, which violate the definition of default isolation level Serializability.
The default isolation level Serializability should see the data committed before the query began.

The initial schema is :

create table table0 (k int primary key, v int);
insert into table0 values(3, 28703);
insert into table0 values(62, 16541);

Then we run:

transaction ID operation
0 START TRANSACTION isolation level serializable
0 SELECT k,v FROM table0 WHERE k=62;
19 START TRANSACTION isolation level serializable
19 UPDATE table0 SET v=15574 WHERE k=3;
19 commit
0 SELECT k,v FROM table0 WHERE k=3;

YugabyteDB version we use is PostgreSQL 11.2-YB-2.17.2.0-b0 on x86_64-pc-linux-gnu, compiled by clang version 15.0.3 (https://github.com/yugabyte/llvm-project.git 0b8d1183745fd3998d8beffeec8cbe99c1b20529), 64-bit.

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@wengsy150943 wengsy150943 added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Apr 25, 2023
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue priority/high High Priority and removed status/awaiting-triage Issue awaiting triage priority/medium Medium priority issue labels Apr 25, 2023
@pkj415
Copy link
Contributor

pkj415 commented Apr 26, 2023

This isn't a bug, just a difference in observed behaviour due to the different implementations for serializable isolation in YugabyteDB vs Postgres. YugabyteDB uses 2PL (two phase locking) whereas Postgres uses SSI (Serializable Snapshot Isolation) for implementing serializability.

  • In Postgres, transaction 0 is ordered (or serialized) before transaction 19
  • In YugabyteDB, transaction 0 is ordered (or serialized) after the transaction 19

Both implementations will honor the correctness guarantee of serializability, they only differ in how they order the transactions.

@m-iancu
Copy link
Contributor

m-iancu commented Apr 26, 2023

Thanks @pkj415. Closing this as duplicate -- Postgres-compatibility of transactions is broadly tracked in this issue: #5683.

@yugabyte-ci yugabyte-ci closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2023
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 priority/high High Priority
Projects
None yet
Development

No branches or pull requests

4 participants