Skip to content

Global variables are not refreshed immediately in a new session #22806

@xhebox

Description

@xhebox

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

[xhe@PC tidb-test]$ cat t5.sh 
#!/bin/sh

mycli -h 127.0.0.1 -P 4000 -u root --no-warn << "EOF"
set global tidb_enable_alter_placement=on;
EOF

mycli -h 127.0.0.1 -P 4000 -u root --no-warn << "EOF"
select @@global.tidb_enable_alter_placement;
drop table if exists test.t1;
create table test.t1 (a int) partition by hash(a) partitions 2;
alter table test.t1 alter partition p0 alter placement policy role=leader;
EOF
[xhe@PC tidb-test]$ cat t4.sh 
#!/bin/sh
mycli -h 127.0.0.1 -P 4000 -u root --no-warn << "EOF"
select @@global.tidb_enable_alter_placement;
drop table if exists test.t1;
create table test.t1 (a int) partition by hash(a) partitions 2;
alter table test.t1 alter partition p0 alter placement policy role=leader;
EOF
# start a new tiup playground
[xhe@PC tidb-test]$ ./t5.sh 
@@global.tidb_enable_alter_placement
1
(1105, 'alter partition alter placement is experimental and it is switched off by tidb_enable_alter_placement')
[xhe@PC tidb-test]$ ./t4.sh 
@@global.tidb_enable_alter_placement
1
# start a new tiup playground
[xhe@PC tidb-test]$ ./t5.sh 
./@@global.tidb_enable_alter_placement
1
(1105, 'alter partition alter placement is experimental and it is switched off by tidb_enable_alter_placement')
[xhe@PC tidb-test]$ ./t4.sh 
@@global.tidb_enable_alter_placement
1
(1105, 'alter partition alter placement is experimental and it is switched off by tidb_enable_alter_placement')
[xhe@PC tidb-test]$ ./t4.sh 
@@global.tidb_enable_alter_placement
1

2. What did you expect to see? (Required)

If I see select @@global.tidb_enable_alter_placement == 1, then the command should execute successfully. In another word, the sessionVars of session should be updated.

3. What did you see instead (Required)

An outdated session variable is causing SQL failure.

4. What is your TiDB version? (Required)

59ccb29, the current/latest master commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues or pull requests already exists.type/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions