yugabyte/yugabyte-db

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

Open

#1,546 opened on 2019年6月14日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)C (1,003 forks)batch import
area/ysqlgood first issuekind/bugpriority/medium

Repository metrics

Stars
 (8,229 stars)
PR merge metrics
 (平均マージ 17d 21h) (30d で 92 merged PRs)

説明

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.

コントリビューターガイド