From fee25e07827623753fef5fe9cfaed3cad70967e5 Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Fri, 12 Mar 2021 01:05:01 +0800 Subject: [PATCH] session: enable async commit in new clusters Signed-off-by: Yilin Chen --- go.sum | 1 - session/bootstrap.go | 6 ++++++ store/tikv/config/client.go | 11 ++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/go.sum b/go.sum index 7c152071e31fd..eb1fdc8363302 100644 --- a/go.sum +++ b/go.sum @@ -466,7 +466,6 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 h1:tB9NOR21++IjLyVx3/PCPhWMwqGNCMQEH96A6dMZ/gc= github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v2.19.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.12+incompatible h1:6VEGkOXP/eP4o2Ilk8cSsX0PhOEfX6leqAnD+urrp9M= diff --git a/session/bootstrap.go b/session/bootstrap.go index 7672d3d6c8c10..96a60d1c65f97 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -1562,6 +1562,12 @@ func doDMLWorks(s Session) { vVal = variable.BoolOn } } + if v.Name == variable.TiDBEnableAsyncCommit && config.GetGlobalConfig().Store == "tikv" { + vVal = variable.BoolOn + } + if v.Name == variable.TiDBEnable1PC && config.GetGlobalConfig().Store == "tikv" { + vVal = variable.BoolOn + } value := fmt.Sprintf(`("%s", "%s")`, strings.ToLower(k), vVal) values = append(values, value) } diff --git a/store/tikv/config/client.go b/store/tikv/config/client.go index d2993a1662a6d..97dc281722093 100644 --- a/store/tikv/config/client.go +++ b/store/tikv/config/client.go @@ -70,15 +70,12 @@ type AsyncCommit struct { KeysLimit uint `toml:"keys-limit" json:"keys-limit"` // Use async commit only if the total size of keys does not exceed TotalKeySizeLimit. TotalKeySizeLimit uint64 `toml:"total-key-size-limit" json:"total-key-size-limit"` - // The following two fields should never be modified by the user, so tags are not provided - // on purpose. // The duration within which is safe for async commit or 1PC to commit with an old schema. - // It is only changed in tests. - // TODO: 1PC is not part of async commit. These two fields should be moved to a more suitable - // place. - SafeWindow time.Duration + // The following two fields should NOT be modified in most cases. If both async commit + // and 1PC are disabled in the whole cluster, they can be set to zero to avoid waiting in DDLs. + SafeWindow time.Duration `toml:"safe-window" json:"safe-window"` // The duration in addition to SafeWindow to make DDL safe. - AllowedClockDrift time.Duration + AllowedClockDrift time.Duration `toml:"allowed-clock-drift" json:"allowed-clock-drift"` } // CoprocessorCache is the config for coprocessor cache.