From a7bc427568a31bd19abbcb9a49846b93e5d81e22 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 17 Aug 2021 20:13:35 +0800 Subject: [PATCH 1/4] Update sql-plan-management.md --- sql-plan-management.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sql-plan-management.md b/sql-plan-management.md index b2cf69acd8969..1d24d62dfd08d 100644 --- a/sql-plan-management.md +++ b/sql-plan-management.md @@ -287,3 +287,40 @@ Because the baseline evolution automatically creates a new binding, when the que | `max_execution_time` | The longest duration for a query. | + `read_from_storage` is a special hint in that it specifies whether to read data from TiKV or from TiFlash when reading tables. Because TiDB provides isolation reads, when the isolation condition changes, this hint has a great influence on the evolved execution plan. Therefore, when this hint exists in the initially created binding, TiDB ignores all its evolved bindings. + +## Upgrade Checklist + +SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You need to check the environment before upgrade to make sure it succeeds. + +* When you upgrade from a version earlier than v5.2.0 (that is, v4.0, v5.0, and v5.1) to the current version, make sure `tidb_evolve_plan_baselines` is disabled. If not, you must disable it before upgrade. Perform the following steps. + {{< copyable "sql" >}} + + ```sql +-- Check whether `tidb_evolve_plan_baselines` is disabled in the earlier version. + + select @@global.tidb_evolve_plan_baselines; + +-- If `tidb_evolve_plan_baselines` is still enabled, disable it. + + set global tidb_evolve_plan_baselines = off; + ``` + +* Before you upgrade from v4.0 to the current version, you must check whether the grammar of all the SQL statements corresponding to available SQL bindings is correct in the new version. If any grammatical errors, delete the corresponding SQL bindings. +Perform the following steps. + +{{< copyable "sql" >}} + + ```sql +-- Check the SQL statements corresponding to available SQL bindings in the version to be upgraded. + + select bind_sql from mysql.bind_info where source != 'builtin' and status = 'using'; + +-- Verify the result from the above SQL query in the test environment of the new version. + + bind_sql_0; + bind_sql_1; + ... + +-- In the case of a syntax error (ERROR 1064 (42000): You have an error in your SQL syntax), delete the corresponding binding. +-- For any other errors (for example, tables are not found), it means the syntax is compatible. No intervention is needed. + ``` From bdea0f5f2036969571ddede58deab1fedc7a4449 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 17 Aug 2021 20:23:51 +0800 Subject: [PATCH 2/4] Update sql-plan-management.md --- sql-plan-management.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sql-plan-management.md b/sql-plan-management.md index 1d24d62dfd08d..e2b8d80da14fb 100644 --- a/sql-plan-management.md +++ b/sql-plan-management.md @@ -293,14 +293,15 @@ Because the baseline evolution automatically creates a new binding, when the que SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You need to check the environment before upgrade to make sure it succeeds. * When you upgrade from a version earlier than v5.2.0 (that is, v4.0, v5.0, and v5.1) to the current version, make sure `tidb_evolve_plan_baselines` is disabled. If not, you must disable it before upgrade. Perform the following steps. + {{< copyable "sql" >}} ```sql --- Check whether `tidb_evolve_plan_baselines` is disabled in the earlier version. + -- Check whether `tidb_evolve_plan_baselines` is disabled in the earlier version. select @@global.tidb_evolve_plan_baselines; --- If `tidb_evolve_plan_baselines` is still enabled, disable it. + -- If `tidb_evolve_plan_baselines` is still enabled, disable it. set global tidb_evolve_plan_baselines = off; ``` @@ -308,19 +309,19 @@ SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You n * Before you upgrade from v4.0 to the current version, you must check whether the grammar of all the SQL statements corresponding to available SQL bindings is correct in the new version. If any grammatical errors, delete the corresponding SQL bindings. Perform the following steps. -{{< copyable "sql" >}} + {{< copyable "sql" >}} ```sql --- Check the SQL statements corresponding to available SQL bindings in the version to be upgraded. + -- Check the SQL statements corresponding to available SQL bindings in the version to be upgraded. select bind_sql from mysql.bind_info where source != 'builtin' and status = 'using'; --- Verify the result from the above SQL query in the test environment of the new version. + -- Verify the result from the above SQL query in the test environment of the new version. bind_sql_0; bind_sql_1; ... --- In the case of a syntax error (ERROR 1064 (42000): You have an error in your SQL syntax), delete the corresponding binding. --- For any other errors (for example, tables are not found), it means the syntax is compatible. No intervention is needed. + -- In the case of a syntax error (ERROR 1064 (42000): You have an error in your SQL syntax), delete the corresponding binding. + -- For any other errors (for example, tables are not found), it means the syntax is compatible. No intervention is needed. ``` From a1d30ca623a35564effb73659926fe19f5cd811d Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 17 Aug 2021 20:33:54 +0800 Subject: [PATCH 3/4] Update sql-plan-management.md --- sql-plan-management.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql-plan-management.md b/sql-plan-management.md index e2b8d80da14fb..4c463b0d857d0 100644 --- a/sql-plan-management.md +++ b/sql-plan-management.md @@ -306,8 +306,7 @@ SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You n set global tidb_evolve_plan_baselines = off; ``` -* Before you upgrade from v4.0 to the current version, you must check whether the grammar of all the SQL statements corresponding to available SQL bindings is correct in the new version. If any grammatical errors, delete the corresponding SQL bindings. -Perform the following steps. +* Before you upgrade from v4.0 to the current version, you must check whether the grammar of all the SQL statements corresponding to available SQL bindings is correct in the new version. If any grammatical errors, delete the corresponding SQL bindings. Perform the following steps. {{< copyable "sql" >}} From d07a7f8f15f199f36270514996751f441e0f6f70 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 20 Aug 2021 10:00:20 +0800 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> Co-authored-by: Chengpeng Yan <41809508+Reminiscent@users.noreply.github.com> --- sql-plan-management.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sql-plan-management.md b/sql-plan-management.md index 4c463b0d857d0..94c52bd1bab4a 100644 --- a/sql-plan-management.md +++ b/sql-plan-management.md @@ -288,11 +288,11 @@ Because the baseline evolution automatically creates a new binding, when the que + `read_from_storage` is a special hint in that it specifies whether to read data from TiKV or from TiFlash when reading tables. Because TiDB provides isolation reads, when the isolation condition changes, this hint has a great influence on the evolved execution plan. Therefore, when this hint exists in the initially created binding, TiDB ignores all its evolved bindings. -## Upgrade Checklist +## Upgrade checklist -SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You need to check the environment before upgrade to make sure it succeeds. +During cluster upgrade, SQL Plan Management (SPM) might cause compatibility issues and make the upgrade fail. To ensure a successful upgrade, you need to include the following list for upgrade precheck: -* When you upgrade from a version earlier than v5.2.0 (that is, v4.0, v5.0, and v5.1) to the current version, make sure `tidb_evolve_plan_baselines` is disabled. If not, you must disable it before upgrade. Perform the following steps. +* When you upgrade from a version earlier than v5.2.0 (that is, v4.0, v5.0, and v5.1) to the current version, make sure that `tidb_evolve_plan_baselines` is disabled before the upgrade. To disable this variable, perform the following steps. {{< copyable "sql" >}} @@ -306,14 +306,14 @@ SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You n set global tidb_evolve_plan_baselines = off; ``` -* Before you upgrade from v4.0 to the current version, you must check whether the grammar of all the SQL statements corresponding to available SQL bindings is correct in the new version. If any grammatical errors, delete the corresponding SQL bindings. Perform the following steps. +* Before you upgrade from v4.0 to the current version, you need to check whether the syntax of all queries corresponding to the available SQL bindings is correct in the new version. If any syntax errors exist, delete the corresponding SQL binding. To do that, perform the following steps. {{< copyable "sql" >}} ```sql - -- Check the SQL statements corresponding to available SQL bindings in the version to be upgraded. + -- Check the query corresponding to the available SQL binding in the version to be upgraded. - select bind_sql from mysql.bind_info where source != 'builtin' and status = 'using'; + select bind_sql from mysql.bind_info where status = 'using'; -- Verify the result from the above SQL query in the test environment of the new version. @@ -322,5 +322,5 @@ SQL Plan Management (SPM) may fail in upgrade due to compatibility issues. You n ... -- In the case of a syntax error (ERROR 1064 (42000): You have an error in your SQL syntax), delete the corresponding binding. - -- For any other errors (for example, tables are not found), it means the syntax is compatible. No intervention is needed. + -- For any other errors (for example, tables are not found), it means that the syntax is compatible. No other operation is needed. ```