yugabyte/yugabyte-db

[YSQL] In a transaction combining YSQL and temporary table, the temporary table txn is committed instead of being rolled back

Open

#1546 aperta il 14 giu 2019

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)C (1003 fork)batch import
area/ysqlgood first issuekind/bugpriority/medium

Metriche repository

Star
 (8229 star)
Metriche merge PR
 (Merge medio 17g 21h) (92 PR mergiate in 30 g)

Descrizione

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.

Guida contributor