-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9645]: YSQL: Cleanup DDL txn state in case of query failure
Summary: DDL transaction state is controlled by the `ddl_nesting_level` counter. When `ddl_nesting_level` is changing from 0 to 1 by the calling of the `YBIncrementDdlNestingLevel` function new DDL transaction is started. When `ddl_nesting_level` is changing from 1 to 0 by the calling of the `YBDecrementDdlNestingLevel` function current DDL transaction is committed. In some scenarios in case of failure the `ddl_nesting_level` counter may have inappropriate value, it is required to reset them and DDL transaction state as well. One of such scenario is the index creation procedure. By design index creation commits current DDL transaction at the middle and starts a new one immediately. For this purpose the `YBDecrementDdlNestingLevel`/`YBIncrementDdlNestingLevel` functions are called from the `DefineIndex` function. But in case current DDL is failed to commit or new DDL transaction can't be started for some reason (due to catalog version change etc) the `YBIncrementDdlNestingLevel` function may not be called or may return error. In this case `ddl_nesting_level` will have wrong value. As a result current SQL session will not be able to start/commit further DDLs at the proper time. Solution is to reset DDL transaction state in case current DDL query finished with an error. Note: As far as DDL transaction state is reset in case of error it is not necessary to have `success` parameter in the `YBDecrementDdlNestingLevel` function (it is called only in case of success) Test Plan: New unit test was introduced ``` ./yb_build.sh --gtest_filter PgDDLConcurrencyTest.IndexCreation ``` Reviewers: mihnea, jason Reviewed By: jason Subscribers: rsami, yql Differential Revision: https://phabricator.dev.yugabyte.com/D12609
- Loading branch information
1 parent
7adb6ff
commit 888c0d6
Showing
12 changed files
with
165 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.