Skip to content

2.25.2.0-b86

@yifanguan yifanguan tagged this 03 Mar 17:08
Summary:
Auto analyze service should skip running ANALYZEs on a database that is being restored. Otherwise, serialization errors can occur between DDL statements in the dump script and ANALYZEs run by auto analyze in the background when a cluster has auto analyze service enabled. These serialization errors occur on the concurrent increments to the catalog version.

To support this, the `yb_disable_auto_analyze` GUC is introduced. By executing `ALTER DATABASE ... SET yb_disable_auto_analyze=on`, a user can stop auto analyze on all tables of the DB. The auto analyze service queries for the value of this GUC before running ANALYZE on tables that have crossed the required mutation threshold. To resume auto analyze again, the user should set the GUC to off.

With this change, ysql_dump will disable auto analyze on the target database before any DDLs are executed and re-enable it after all DDLs are done if:
(1) `--format p` (which is the default plain text output format) is used,
(2) `--include-yb-metadata` is specified and
(3) `--create` is not specified (this is because if output script also has to create the database, we need to disable auto analyze after the creation. This will be done in a follow-up revision).

This change also disables auto analyze during a YSQL major version upgrade.

## Cross-version backup/restore compatibility:
To maintain backwards compatibility i.e., when running restore on a db version without this GUC, the restore script checks for the presence of the GUC before setting it on the database using ALTER DATABASE.
Jira: DB-13797

Test Plan:
./yb_build.sh release --gtest_filter PgAutoAnalyzeTest.DisableAndReEnableAutoAnalyze
./yb_build.sh release --cxx-test yb-backup-cross-feature-test --gtest-filter YBBackupTest.TestAutoAnalyzeEnabledDuringRestore
./yb_build.sh release --java-test org.yb.pgsql.TestYsqlDump
./yb_build.sh release --java-test org.yb.pgsql.TestYsqlUpgrade

Reviewers: mihnea, hsunder, yguan, sanketh

Reviewed By: hsunder

Subscribers: sanketh, smishra, ybase, loginov, yql

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