Skip to content

Commit c6a3ee1

Browse files
pkj415avoidik
authored andcommitted
[#29239] YSQL: Guardrail to prevent autonomous txn in transaction block
Summary: Some DDLs can run as autonomous transactions (i.e., not part of a transaction block) even if transactional DDL mode (ysql_yb_ddl_transaction_block_enabled) is on. Currently, the only example is `CREATE INDEX CONCURRENTLY`. Autonomous DDL transactions use the kDDL session on the local tserver proxy. Currently, it is not possible to run an autonomous DDL transaction while a regular transaction block is active (which uses the kPlain session on the local tserver proxy). Some of our code relies on this fact. This revision adds a check to ensure that this assumption is not violated. Jira: DB-19011 Test Plan: Jenkins Reviewers: stiwary Reviewed By: stiwary Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D48027
1 parent 1c0ee11 commit c6a3ee1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/postgres/src/backend/utils/misc/pg_yb_utils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,12 @@ YbTrackAlteredTableId(Oid relid)
26472647
void
26482648
YBIncrementDdlNestingLevel(YbDdlMode mode)
26492649
{
2650+
if (YBIsDdlTransactionBlockEnabled() && IsTransactionBlock())
2651+
{
2652+
elog(ERROR,
2653+
"YBIncrementDdlNestingLevel: autonomous DDL not exepcted inside a transaction block");
2654+
}
2655+
26502656
if (ddl_transaction_state.nesting_level == 0)
26512657
{
26522658
/*

0 commit comments

Comments
 (0)