From 6c9ee36e8e7c86abbda374d841b019979ff3aaf4 Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Wed, 8 Jan 2025 12:00:34 +0800 Subject: [PATCH] var: enable `pd_enable_follower_handle_region` as default (#58385) close pingcap/tidb#58384 --- pkg/executor/set_test.go | 4 +- pkg/metrics/grafana/tidb.json | 105 ++++++++++++++++++++ pkg/sessionctx/variable/tidb_vars.go | 2 +- tests/integrationtest/r/session/vars.result | 8 +- tests/integrationtest/t/session/vars.test | 4 +- 5 files changed, 114 insertions(+), 9 deletions(-) diff --git a/pkg/executor/set_test.go b/pkg/executor/set_test.go index f4111f6cd8129..44c3e0e224ec4 100644 --- a/pkg/executor/set_test.go +++ b/pkg/executor/set_test.go @@ -655,11 +655,11 @@ func TestSetVar(t *testing.T) { tk.MustExec("set global tidb_enable_tso_follower_proxy = 0") tk.MustQuery("select @@tidb_enable_tso_follower_proxy").Check(testkit.Rows("0")) require.Error(t, tk.ExecToErr("set tidb_enable_tso_follower_proxy = 1")) - tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("0")) - tk.MustExec("set global pd_enable_follower_handle_region = 1") tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("1")) tk.MustExec("set global pd_enable_follower_handle_region = 0") tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("0")) + tk.MustExec("set global pd_enable_follower_handle_region = 1") + tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("1")) require.Error(t, tk.ExecToErr("set pd_enable_follower_handle_region = 1")) tk.MustQuery("select @@tidb_enable_historical_stats").Check(testkit.Rows("0")) diff --git a/pkg/metrics/grafana/tidb.json b/pkg/metrics/grafana/tidb.json index 096e2facfd2e7..5d4368d8f7cf5 100644 --- a/pkg/metrics/grafana/tidb.json +++ b/pkg/metrics/grafana/tidb.json @@ -13336,6 +13336,111 @@ "alignLevel": null } }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TEST-CLUSTER}", + "description": "The stale regions from PD per second.", + "editable": true, + "error": false, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 0, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 37 + }, + "hiddenSeries": false, + "id": 339, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.11", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "sum(rate(tidb_tikvclient_stale_region_from_pd{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}[30s]))", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "all", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Stale Region From PD", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ops", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, { "aliasColors": {}, "bars": false, diff --git a/pkg/sessionctx/variable/tidb_vars.go b/pkg/sessionctx/variable/tidb_vars.go index 09d18f75188b4..89bb6a47d79cc 100644 --- a/pkg/sessionctx/variable/tidb_vars.go +++ b/pkg/sessionctx/variable/tidb_vars.go @@ -1388,7 +1388,7 @@ const ( DefTiDBEnableLocalTxn = false DefTiDBTSOClientBatchMaxWaitTime = 0.0 // 0ms DefTiDBEnableTSOFollowerProxy = false - DefPDEnableFollowerHandleRegion = false + DefPDEnableFollowerHandleRegion = true DefTiDBEnableOrderedResultMode = false DefTiDBEnablePseudoForOutdatedStats = false DefTiDBRegardNULLAsPoint = true diff --git a/tests/integrationtest/r/session/vars.result b/tests/integrationtest/r/session/vars.result index 2f354c8baadcc..ca7114556ca00 100644 --- a/tests/integrationtest/r/session/vars.result +++ b/tests/integrationtest/r/session/vars.result @@ -64,15 +64,15 @@ select @@tidb_enable_tso_follower_proxy; 0 select @@pd_enable_follower_handle_region; @@pd_enable_follower_handle_region -0 -set global pd_enable_follower_handle_region = on; -select @@pd_enable_follower_handle_region; -@@pd_enable_follower_handle_region 1 set global pd_enable_follower_handle_region = off; select @@pd_enable_follower_handle_region; @@pd_enable_follower_handle_region 0 +set global pd_enable_follower_handle_region = on; +select @@pd_enable_follower_handle_region; +@@pd_enable_follower_handle_region +1 set tidb_tso_client_batch_max_wait_time = 0; Error 1229 (HY000): Variable 'tidb_tso_client_batch_max_wait_time' is a GLOBAL variable and should be set with SET GLOBAL set global tidb_enable_tso_follower_proxy = default; diff --git a/tests/integrationtest/t/session/vars.test b/tests/integrationtest/t/session/vars.test index 0f7d4fc12b760..ea648134cb67c 100644 --- a/tests/integrationtest/t/session/vars.test +++ b/tests/integrationtest/t/session/vars.test @@ -36,10 +36,10 @@ select @@tidb_enable_tso_follower_proxy; set global tidb_enable_tso_follower_proxy = off; select @@tidb_enable_tso_follower_proxy; select @@pd_enable_follower_handle_region; -set global pd_enable_follower_handle_region = on; -select @@pd_enable_follower_handle_region; set global pd_enable_follower_handle_region = off; select @@pd_enable_follower_handle_region; +set global pd_enable_follower_handle_region = on; +select @@pd_enable_follower_handle_region; -- error 1229 set tidb_tso_client_batch_max_wait_time = 0; set global tidb_enable_tso_follower_proxy = default;