-
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.
[BACKPORT 2024.2][#25392] YSQL: make alter database statement non-glo…
…bal impact Summary: Currently alter database statement has global impact when incrementing catalog version because it writes pg_database which is a shared relation. As a result it can cause symptom such as: Scheduled run_maintenance job for PG Partman failed on one database while a backup was being restored on another. The error looks like ``` 2024-12-16 16:54:39.544 UTC [101015] ERROR: The catalog snapshot used for this transaction has been invalidated: expected: 124, got: 123: MISMATCHED_SCHEMA ``` The above error was caused by a global-impact alter database DDL: ``` ALTER DATABASE "db_timestamp_1" OWNER TO postgres ``` In reality, there is no need for the alter database statement to increment the catalog version of all databases. There is only one database that is altered and we should increment the catalog version of "db_timestamp_1", which may not be MyDatabaseId (OID of the database that the current session is connected to). This diff makes an optimization to only increment the catalog version of the database that is being altered for a set of common alter database statements. Note that this is an optimization in the sense that it is not incorrect to increment catalog versions of all the databases: in that case we will be rejecting more queries than necessary but will not wrongly accept more queries. Added new unit tests that do some sanity tests to show the same behavior as native PG (except when more than one nodes are involved). Jira: DB-14621 Original commit: 3b31c0b / D40959 Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgCatalogConsistency#testAlterDatabaseSetResetGucTestDb' ./yb_build.sh --java-test 'org.yb.pgsql.TestPgCatalogConsistency#testAlterDatabaseSetResetGucDefaultDb' ./yb_build.sh --cxx-test pg_catalog_version-test Reviewers: kfranz, mihnea, loginov, #db-approvers Reviewed By: kfranz, #db-approvers Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D41212
- Loading branch information
Showing
5 changed files
with
217 additions
and
15 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