Skip to content

2.27.0.0-b192

@fizaaluthra fizaaluthra tagged this 05 Jun 14:55
Summary:
Rewrites on empty temp tables fail on YB after the PG15 merge:
```
yugabyte=# create temp table p(f1 int, f2 int);
CREATE TABLE
yugabyte=# alter table p alter column f2 type bigint;
ERROR:  cannot commit a transaction that deleted files but has no xid
WARNING:  AbortTransaction while in COMMIT state
```

This happens because `RecordTransactionCommit` now expects a valid transaction id when `ndroppedstats != 0` (introduced by upstream PG commit 8b1dccd37c71ed2ff016294d8f9053a32b02b19e).

Typically for a temp table rewrite, we generate an XID when we do a `heap_insert` (as we set YbSetTxnWithPgOps(YB_TXN_USES_TEMPORARY_RELATIONS) inside ATRewriteTables). However, if the table is empty, heap_insert is never called, and the XID is never generated in YB.

Vanilla PG generates the XID when it executes `LockAcquireExtended`, which is not used in YB.

Fix the issue by invoking `YbSetTxnWithPgOps(YB_TXN_USES_TEMPORARY_RELATIONS)` along with `GetCurrentTransactionId` in `pg_yb_utils.c`. Do this for all temp table `ALTER`s, `CREATE`s and `CREATE INDEX`es, and any `DROP TABLE`s that contain a temp table to keep the behaviour consistent across different temp table DDLs, i.e., always generate an XID for temp table transactions.

With this revision, we will always set `YB_TXN_USES_TEMPORARY_RELATIONS` for concurrent refreshes on matviews, so the logic in xact.c will not be executed. Clean up this logic, and also remove `YB_TXN_USES_REFRESH_MAT_VIEW_CONCURRENTLY` entirely as it is no longer required.

This also fixes GH#26677
Jira: DB-15720

Test Plan:
./yb_build.sh release --java-test 'org.yb.pgsql.TestPgRegressMatview'
./yb_build.sh release --java-test 'org.yb.pgsql.TestPgRegressFeature'

Reviewers: kramanathan

Reviewed By: kramanathan

Subscribers: yql

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