Skip to content

[Fix](variables) fix session variable does not take effect immediately when set global variable in follower FE#18609

Merged
yiguolei merged 2 commits intoapache:masterfrom
Cai-Yao:fix_04_12
Apr 14, 2023
Merged

[Fix](variables) fix session variable does not take effect immediately when set global variable in follower FE#18609
yiguolei merged 2 commits intoapache:masterfrom
Cai-Yao:fix_04_12

Conversation

@Cai-Yao
Copy link
Contributor

@Cai-Yao Cai-Yao commented Apr 12, 2023

Proposed changes

Issue Number: close #xxx

Problem summary

For the non-master node, the set global xxx = xxx will not change the variables of the current session, because of forward() to master node execute.
So the set global xxx = xxx needs to be executed again to change the current session after forward().

This PR will change behavior, but I think the old behavior is a bug.

Checklist(Required)

  • Does it affect the original behavior
  • Has unit tests been added
  • Has document been added or modified
  • Does it need to update dependencies
  • Is this PR support rollback (If NO, please explain WHY)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

yiguolei
yiguolei previously approved these changes Apr 13, 2023
Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yiguolei
Copy link
Contributor

run buildall

@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Apr 13, 2023
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

if (parsedStmt instanceof SetStmt) {
SetExecutor executor = new SetExecutor(ctx, (SetStmt) parsedStmt);
try {
executor.setSessionVars();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can set remove the global property in SetStmt and than call executor.execute() method. No need to create a new method setSessionVars().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can set remove the global property in SetStmt and than call executor.execute() method. No need to create a new method setSessionVars().

Ok, I see what you mean.

}

private boolean isSessionVar(SetVar var) {
return !(var instanceof SetPassVar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is error-prone, if other people at a new subclass of SetVar, this method may be missed.
How about add a SetVarType or something to specify the stmt's type directly?
And write like return var.setType() == Type.SET_SESSION_VAR;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is error-prone, if other people at a new subclass of SetVar, this method may be missed. How about add a SetVarType or something to specify the stmt's type directly? And write like return var.setType() == Type.SET_SESSION_VAR;

Yes, I will modify it.

@github-actions github-actions bot added area/planner Issues or PRs related to the query planner and removed approved Indicates a PR has been approved by one committer. labels Apr 13, 2023
@yiguolei
Copy link
Contributor

run buildall

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 13, 2023
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@yiguolei yiguolei merged commit 183800e into apache:master Apr 14, 2023
gnehil pushed a commit to gnehil/doris that referenced this pull request Apr 21, 2023
morningman added a commit that referenced this pull request Apr 25, 2023
…on master FE (#18949)

Introduced from #18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Apr 25, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
xiaokang pushed a commit to xiaokang/doris that referenced this pull request Apr 28, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
xiaokang pushed a commit to xiaokang/doris that referenced this pull request Apr 28, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
Reminiscent pushed a commit to Reminiscent/doris that referenced this pull request May 15, 2023
Reminiscent pushed a commit to Reminiscent/doris that referenced this pull request May 15, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Jul 13, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Jul 25, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Aug 15, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Aug 16, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Aug 29, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
gnehil pushed a commit to gnehil/doris that referenced this pull request Sep 1, 2023
…on master FE (apache#18949)

Introduced from apache#18609.

When setting global variables from Non Master FE, there will be error like:

`Variable 'password_history' is a GLOBAL variable and should be set with SET GLOBAL`

Because when setting global variables from Non Master FE, Doris will do following step:

1. forward this SetStmt to Master FE to execute.
2. Change this SetStmt to "SESSION" level, and execute it again on this Non Master FE.

But for "GLOBAL only" variable, such ash "password_history", it doesn't allow to set on SESSION level.
So when doing step 2, "set password_history=xxx" without "GLOBAL" keywords will throw exception.
So in this case, we should just ignore this exception and return.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/planner Issues or PRs related to the query planner reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants