diff --git a/br/pkg/lightning/backend/kv/session.go b/br/pkg/lightning/backend/kv/session.go index c5b623b31fd24..b817d332faa94 100644 --- a/br/pkg/lightning/backend/kv/session.go +++ b/br/pkg/lightning/backend/kv/session.go @@ -264,6 +264,16 @@ func newSession(options *SessionOptions, logger log.Logger) *session { vars.SQLMode = sqlMode if options.SysVars != nil { for k, v := range options.SysVars { + // since 6.3(current master) tidb checks whether we can set a system variable + // lc_time_names is a read-only variable for now, but might be implemented later, + // so we not remove it from defaultImportantVariables and check it in below way. + if sv := variable.GetSysVar(k); sv == nil { + logger.DPanic("unknown system var", zap.String("key", k)) + continue + } else if sv.ReadOnly { + logger.Debug("skip read-only variable", zap.String("key", k)) + continue + } if err := vars.SetSystemVar(k, v); err != nil { logger.DPanic("new session: failed to set system var", log.ShortError(err), diff --git a/br/tests/lightning_local_backend/run.sh b/br/tests/lightning_local_backend/run.sh index b1c7440249c27..5177f98d1ecba 100755 --- a/br/tests/lightning_local_backend/run.sh +++ b/br/tests/lightning_local_backend/run.sh @@ -20,6 +20,8 @@ check_cluster_version 4 0 0 'local backend' || exit 0 ENGINE_COUNT=6 +res_file="$TEST_DIR/sql_res.$TEST_NAME.txt" + # Test check table contains data rm -f "/tmp/tidb_lightning_checkpoint_local_backend_test.pb" rm -rf $TEST_DIR/lightning.log @@ -80,7 +82,11 @@ set -e export GO_FAILPOINTS='' echo "******** Verify checkpoint no-op ********" -run_lightning --backend local --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-local.log" --config "tests/$TEST_NAME/config.toml" +run_lightning --backend local --enable-checkpoint=1 --config "tests/$TEST_NAME/config.toml" --log-file $res_file -L debug +check_not_contains "failed to set system var" +check_not_contains "unknown system var" +check_contains "skip read-only variable" +check_contains "lc_time_names" run_sql 'SELECT count(*), sum(c) FROM cpeng.a' check_contains 'count(*): 4'