Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightning: fix dpanic log when init session vars #37301

Merged
merged 6 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 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,15 @@ 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.
if sv := variable.GetSysVar(k); sv == nil {
logger.DPanic("unknown system var", zap.String("key", k))
continue
} else if sv.ReadOnly {
logger.Info("skip read-only variable", zap.String("key", k))
continue
}
sleepymole marked this conversation as resolved.
Show resolved Hide resolved
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" > $res_file 2>&1
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