Skip to content

2.27.0.0-b190

@dr0pdb dr0pdb tagged this 05 Jun 10:12
Summary:
A temp table can be created with an on-commit action to delete all rows post commit. Before this revision, we commit the DocDB transaction before executing
these actions. As a result, when these on-commit actions (truncate) acquire a lock, it leads to the PG layer setting the state for a new transaction (from the
`CalculateIsolation` function) which never gets cleaned up. So future statements after the commit end up getting the error "Transaction is already in progress".

Example:
```
BEGIN ISOLATION LEVEL REPEATABLE READ;

CREATE TEMPORARY TABLE p (
    a INT PRIMARY KEY
) ON COMMIT DELETE ROWS;

INSERT INTO p VALUES (1);
INSERT INTO p VALUES (2);

SELECT * FROM p;  -- Succeeds, returns 2 rows

COMMIT; -- Commit succeeds but sets up state during on-commit handling

SELECT * FROM p;  -- Fails with ERROR: Transaction is already in progress
```

This revision fixes the issue by simply moving the DocDB transaction commit after we are done with handling on-commit actions. This is correct because such actions
should also be considered part of the main transaction.
Jira: DB-1839, DB-16810

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestDdlTransactionBlocks'

Reviewers: myang, patnaik.balivada, bkolagani, #db-approvers

Reviewed By: myang, patnaik.balivada, #db-approvers

Subscribers: svc_phabricator, yql

Differential Revision: https://phorge.dev.yugabyte.com/D44141
Assets 2
Loading