This is an automated email from the ASF dual-hosted git repository.

zouxinyi 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 2005fee4303 [fix](user) Avoid throw unknown UserProperty after FE 
rollback version (#28325)
2005fee4303 is described below

commit 2005fee4303246b00f48e12969a83dc98fcd4b06
Author: Xinyi Zou <zouxiny...@gmail.com>
AuthorDate: Wed Dec 13 16:00:04 2023 +0800

    [fix](user) Avoid throw unknown UserProperty after FE rollback version 
(#28325)
    
    After using SET PROPERTY to modify the user property, if FE rolls back to a 
version without this property, `Unknown user property` error will be reported 
when replay EditLog, just ignore it.
---
 .../java/org/apache/doris/mysql/privilege/Auth.java  |  2 +-
 .../apache/doris/mysql/privilege/UserProperty.java   | 20 +++++++++++++++++++-
 .../doris/mysql/privilege/UserPropertyMgr.java       |  5 +++--
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java
index 4a5400629ed..b503a5e69e0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java
@@ -954,7 +954,7 @@ public class Auth implements Writable {
             throws UserException {
         writeLock();
         try {
-            propertyMgr.updateUserProperty(user, properties);
+            propertyMgr.updateUserProperty(user, properties, isReplay);
             if (!isReplay) {
                 UserPropertyInfo propertyInfo = new UserPropertyInfo(user, 
properties);
                 
Env.getCurrentEnv().getEditLog().logUpdateUserProperty(propertyInfo);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java
index 021bdeb3263..2ee8bc1e82c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java
@@ -37,6 +37,8 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -51,8 +53,13 @@ import java.util.regex.Pattern;
 /*
  * UserProperty contains properties set for a user
  * This user is just qualified by cluster name, not host which it connected 
from.
+ *
+ * If UserProperty and SessionVeriable have the same name, UserProperty has a 
higher priority than SessionVeriable.
+ * This usually means that the cluster administrator force user restrictions.
+ * Users cannot modify these SessionVeriables with the same name.
  */
 public class UserProperty implements Writable {
+    private static final Logger LOG = LogManager.getLogger(UserProperty.class);
     // advanced properties
     private static final String PROP_MAX_USER_CONNECTIONS = 
"max_user_connections";
     private static final String PROP_MAX_QUERY_INSTANCES = 
"max_query_instances";
@@ -173,6 +180,10 @@ public class UserProperty implements Writable {
     }
 
     public void update(List<Pair<String, String>> properties) throws 
UserException {
+        update(properties, false);
+    }
+
+    public void update(List<Pair<String, String>> properties, boolean 
isReplay) throws UserException {
         // copy
         long newMaxConn = this.commonProperties.getMaxConn();
         long newMaxQueryInstances = 
this.commonProperties.getMaxQueryInstances();
@@ -312,7 +323,14 @@ public class UserProperty implements Writable {
                 }
                 workloadGroup = value;
             } else {
-                throw new DdlException("Unknown user property(" + key + ")");
+                if (isReplay) {
+                    // After using SET PROPERTY to modify the user property, 
if FE rolls back to a version without
+                    // this property, `Unknown user property` error will be 
reported when replay EditLog,
+                    // just ignore it.
+                    LOG.warn("Unknown user property(" + key + "), maybe FE 
rolled back version, Ignore it");
+                } else {
+                    throw new DdlException("Unknown user property(" + key + 
")");
+                }
             }
         }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java
index 46f900f655a..d4d34af2538 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java
@@ -73,13 +73,14 @@ public class UserPropertyMgr implements Writable {
         }
     }
 
-    public void updateUserProperty(String user, List<Pair<String, String>> 
properties) throws UserException {
+    public void updateUserProperty(String user, List<Pair<String, String>> 
properties, boolean isReplay)
+            throws UserException {
         UserProperty property = propertyMap.get(user);
         if (property == null) {
             throw new DdlException("Unknown user(" + user + ")");
         }
 
-        property.update(properties);
+        property.update(properties, isReplay);
     }
 
     public int getQueryTimeout(String qualifiedUser) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to