Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] ANALYZE <multiple-tables> commits kPlain transaction while DDL transaction is active #22353

Open
1 task done
karthik-ramanathan-3006 opened this issue May 10, 2024 · 0 comments
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage

Comments

@karthik-ramanathan-3006
Copy link
Contributor

karthik-ramanathan-3006 commented May 10, 2024

Jira Link: DB-11258

Description

From vanilla postgres comments in vacuum.c:

/*
* vacuum_rel expects to be entered with no transaction active; it will
* start and commit its own transaction.  But we are called by an SQL
* command, and so we are executing inside a transaction already. We
* commit the transaction started in PostgresMain() here, and start
* another one before exiting to match the commit waiting for us back in
* PostgresMain().
*/

Thus the vanilla PG vacuum/analyze code attempts to commit any ongoing transaction that may have been active.
In YB, we begin a DDL transaction as part of the YBTxnDdlProcessUtility before entering into the vacuuming/analyzing code flow. This leads to CommitTransaction in pg_txn_manager.cc being called which ignores any active DDL transactions.
This behavior might be unintentional and this assumption might lead to errors in the future.

To repro this issue, add the following check to pg_txn_manager.cc:

Status PgTxnManager::CommitPlainTransaction() {
+  SCHECK(!IsDdlMode(), InternalError, "Received DML txn commit with DDL txn state active");
  return FinishPlainTransaction(Commit::kTrue);
}

Run an ANALYZE command spanning multiple tables and observe the above error message:
ANALYZE <tbl1>, <tbl2>;

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@karthik-ramanathan-3006 karthik-ramanathan-3006 added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels May 10, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants