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 4a5400629e..b503a5e69e 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 021bdeb326..2ee8bc1e82 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> properties) throws UserException { + update(properties, false); + } + + public void update(List> 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 46f900f655..d4d34af253 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> properties) throws UserException { + public void updateUserProperty(String user, List> 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) {