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 创建于 2019年6月14日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)C (1,003 fork)batch import
area/ysqlgood first issuekind/bugpriority/medium

仓库指标

Star
 (8,229 star)
PR 合并指标
 (平均合并 17天 21小时) (30 天内合并 92 个 PR)

描述

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.

贡献者指南