Skip to content

Commit

Permalink
lightning: fix dpanic log when init session vars (#37301)
Browse files Browse the repository at this point in the history
close #37266
  • Loading branch information
D3Hunter authored Aug 24, 2022
1 parent eb8fc86 commit 29b57e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions br/pkg/lightning/backend/kv/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 7 additions & 1 deletion br/tests/lightning_local_backend/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 29b57e3

Please sign in to comment.