You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/14 02:35:10 UTC
[doris] branch master updated: [Fix](variables) fix session variable does not take effect immediately when set global variable in follower FE (#18609)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 183800e1ad [Fix](variables) fix session variable does not take effect immediately when set global variable in follower FE (#18609)
183800e1ad is described below
commit 183800e1adfd5a70512a8accf699f7e427222de7
Author: WenYao <72...@qq.com>
AuthorDate: Fri Apr 14 10:35:03 2023 +0800
[Fix](variables) fix session variable does not take effect immediately when set global variable in follower FE (#18609)
---
.../org/apache/doris/analysis/SetLdapPassVar.java | 1 +
.../java/org/apache/doris/analysis/SetNamesVar.java | 1 +
.../java/org/apache/doris/analysis/SetPassVar.java | 1 +
.../java/org/apache/doris/analysis/SetStmt.java | 11 +++++++++++
.../org/apache/doris/analysis/SetTransaction.java | 1 +
.../apache/doris/analysis/SetUserPropertyVar.java | 1 +
.../main/java/org/apache/doris/analysis/SetVar.java | 21 +++++++++++++++++++++
.../main/java/org/apache/doris/qe/StmtExecutor.java | 6 ++++++
.../main/java/org/apache/doris/qe/VariableMgr.java | 3 ++-
9 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetLdapPassVar.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetLdapPassVar.java
index 0250deeddc..91e4d8e3d7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetLdapPassVar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetLdapPassVar.java
@@ -30,6 +30,7 @@ public class SetLdapPassVar extends SetVar {
public SetLdapPassVar(PassVar passVar) {
this.passVar = passVar;
+ this.varType = SetVarType.SET_LDAP_PASS_VAR;
}
public String getLdapPassword() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetNamesVar.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetNamesVar.java
index efca533da6..a4db25022e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetNamesVar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetNamesVar.java
@@ -31,6 +31,7 @@ public class SetNamesVar extends SetVar {
public SetNamesVar(String charsetName) {
this(charsetName, null);
+ this.varType = SetVarType.SET_NAMES_VAR;
}
public SetNamesVar(String charsetName, String collate) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetPassVar.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetPassVar.java
index 99897ddb3f..911990e618 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetPassVar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetPassVar.java
@@ -36,6 +36,7 @@ public class SetPassVar extends SetVar {
public SetPassVar(UserIdentity userIdent, PassVar passVar) {
this.userIdent = userIdent;
this.passVar = passVar;
+ this.varType = SetVarType.SET_PASS_VAR;
}
public UserIdentity getUserIdent() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetStmt.java
index d6f2382e8e..5e0d0f9105 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetStmt.java
@@ -35,6 +35,17 @@ public class SetStmt extends StatementBase {
return setVars;
}
+ // remove setvar of non-set-session-var,
+ // change type global to session avoid to write in non-master node.
+ public void modifySetVarsForExecute() {
+ setVars.removeIf(setVar -> setVar.getVarType() != SetVar.SetVarType.SET_SESSION_VAR);
+ for (SetVar var : setVars) {
+ if (var.getType() == SetType.GLOBAL) {
+ var.setType(SetType.SESSION);
+ }
+ }
+ }
+
@Override
public boolean needAuditEncryption() {
for (SetVar var : setVars) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetTransaction.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetTransaction.java
index 96fe38da3e..47bf4cd234 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetTransaction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetTransaction.java
@@ -19,6 +19,7 @@ package org.apache.doris.analysis;
public class SetTransaction extends SetVar {
public SetTransaction() {
+ this.varType = SetVarType.SET_TRANSACTION;
}
@Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetUserPropertyVar.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetUserPropertyVar.java
index 55aa5674c8..37f3318a89 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetUserPropertyVar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetUserPropertyVar.java
@@ -39,6 +39,7 @@ public class SetUserPropertyVar extends SetVar {
public SetUserPropertyVar(String key, String value) {
this.key = key;
this.value = value;
+ this.varType = SetVarType.SET_USER_PROPERTY_VAR;
}
public String getPropertyKey() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetVar.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetVar.java
index 88cc3798c5..b853615ae7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetVar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetVar.java
@@ -35,9 +35,20 @@ import com.google.common.base.Strings;
// change one variable.
public class SetVar {
+ public enum SetVarType {
+ DEFAULT,
+ SET_SESSION_VAR,
+ SET_PASS_VAR,
+ SET_LDAP_PASS_VAR,
+ SET_NAMES_VAR,
+ SET_TRANSACTION,
+ SET_USER_PROPERTY_VAR
+ }
+
private String variable;
private Expr value;
private SetType type;
+ public SetVarType varType;
private LiteralExpr result;
public SetVar() {
@@ -45,6 +56,7 @@ public class SetVar {
public SetVar(SetType type, String variable, Expr value) {
this.type = type;
+ this.varType = SetVarType.SET_SESSION_VAR;
this.variable = variable;
this.value = value;
if (value instanceof LiteralExpr) {
@@ -54,6 +66,7 @@ public class SetVar {
public SetVar(String variable, Expr value) {
this.type = SetType.DEFAULT;
+ this.varType = SetVarType.SET_SESSION_VAR;
this.variable = variable;
this.value = value;
if (value instanceof LiteralExpr) {
@@ -77,6 +90,14 @@ public class SetVar {
this.type = type;
}
+ public SetVarType getVarType() {
+ return varType;
+ }
+
+ public void setVarType(SetVarType varType) {
+ this.varType = varType;
+ }
+
// Value can be null. When value is null, means to set variable to DEFAULT.
public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
if (type == null) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 6f615a6260..454012875d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -783,6 +783,12 @@ public class StmtExecutor implements ProfileWriter {
masterOpExecutor = new MasterOpExecutor(originStmt, context, redirectStatus, isQuery());
LOG.debug("need to transfer to Master. stmt: {}", context.getStmtId());
masterOpExecutor.execute();
+ if (parsedStmt instanceof SetStmt) {
+ SetStmt setStmt = (SetStmt) parsedStmt;
+ setStmt.modifySetVarsForExecute();
+ SetExecutor executor = new SetExecutor(context, setStmt);
+ executor.execute();
+ }
}
@Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
index 2658a5cd1f..660a5c5f89 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
@@ -241,7 +241,8 @@ public class VariableMgr {
// Input:
// sessionVariable: the variable of current session
// setVar: variable information that needs to be set
- public static void setVar(SessionVariable sessionVariable, SetVar setVar) throws DdlException {
+ public static void setVar(SessionVariable sessionVariable, SetVar setVar)
+ throws DdlException {
VarContext ctx = ctxByVarName.get(setVar.getVariable());
if (ctx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org