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] In a transaction combining YSQL and temporary table, the temporary table txn is committed instead of being rolled back #1546

Open
d-uspenskiy opened this issue Jun 14, 2019 · 1 comment
Labels
area/ysql Yugabyte SQL (YSQL) good first issue This is a good issue to start contributing! kind/bug This issue is a bug priority/medium Medium priority issue
Projects

Comments

@d-uspenskiy
Copy link
Contributor

d-uspenskiy commented Jun 14, 2019

Jira Link: DB-1588
regular + temp tables in one transaction works incorrectly

Scenario:

  • session_1 creates temp table + regular table with unique index. When starts transaction and inserts some values
postgres=# create table reg_tbl(k int, v int);
CREATE TABLE
postgres=# create unique index on reg_tbl(k);
CREATE INDEX
postgres=# create temp table tmp_tbl(v int);
CREATE TABLE
postgres=# create temp table tmp_tbl(v int);
CREATE TABLE

postgres=# BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN
postgres=# insert into tmp_tbl values(1);
INSERT 0 1
  • at this point session_2 inserts value into regular table
postgres=# insert into reg_tbl values(2, 2);
INSERT 0 1
  • session_1 inserts same value and commits transaction
postgres=# insert into reg_tbl values(2, 2);
INSERT 0 1
postgres=# commit;
ERROR:  Error during commit: Operation expired: Transaction expired
  • at this point tmp_tbl has value in spite of the fact transaction was rolled back
postgres=# select * from tmp_tbl;
 v 
---
 1
(1 row)

Note: problem is not 100% reproducible, often session_1 detects that reg_tbl already have value 2 on attemp to insert it. But I was able to reproduce it several times.

@d-uspenskiy
Copy link
Contributor Author

Comment from @mbautin

I think we should commit the YB transaction first, and only if that succeeds, commit the temporary table transaction.
My understanding is that temporary table transaction commit should never fail.

@d-uspenskiy d-uspenskiy added this to To do in YSQL via automation Jun 14, 2019
@d-uspenskiy d-uspenskiy added kind/bug This issue is a bug area/ysql Yugabyte SQL (YSQL) labels Jun 14, 2019
@mbautin mbautin changed the title [YSQL] Postgres commits native transaction instead of rollback [YSQL] In a transaction combining YSQL and temporary table, the temporary table txn is committed instead of being rolled back Jun 16, 2019
@ndeodhar ndeodhar assigned frozenspider and unassigned mbautin Sep 19, 2019
@ndeodhar ndeodhar moved this from To do to Backlog in YSQL Aug 5, 2020
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Jun 8, 2022
@yugabyte-ci yugabyte-ci added priority/high High Priority and removed priority/medium Medium priority issue labels Aug 31, 2023
@yugabyte-ci yugabyte-ci added priority/medium Medium priority issue good first issue This is a good issue to start contributing! and removed priority/high High Priority labels Oct 16, 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) good first issue This is a good issue to start contributing! kind/bug This issue is a bug priority/medium Medium priority issue
Projects
Status: No status
YSQL
  
Backlog
Development

No branches or pull requests

5 participants