Skip to content

Commit d037d58

Browse files
xinyiZzzDoris-Extras
authored andcommitted
[fix](user) Avoid throw unknown UserProperty after FE rollback version (apache#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.
1 parent 7ccc4cb commit d037d58

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ public void updateUserPropertyInternal(String user, List<Pair<String, String>> p
953953
throws UserException {
954954
writeLock();
955955
try {
956-
propertyMgr.updateUserProperty(user, properties);
956+
propertyMgr.updateUserProperty(user, properties, isReplay);
957957
if (!isReplay) {
958958
UserPropertyInfo propertyInfo = new UserPropertyInfo(user, properties);
959959
Env.getCurrentEnv().getEditLog().logUpdateUserProperty(propertyInfo);

fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import com.google.common.collect.Maps;
3737
import com.google.common.collect.Sets;
3838
import org.apache.commons.lang3.StringUtils;
39+
import org.apache.logging.log4j.LogManager;
40+
import org.apache.logging.log4j.Logger;
3941

4042
import java.io.DataInput;
4143
import java.io.DataOutput;
@@ -50,8 +52,13 @@
5052
/*
5153
* UserProperty contains properties set for a user
5254
* This user is just qualified by cluster name, not host which it connected from.
55+
*
56+
* If UserProperty and SessionVeriable have the same name, UserProperty has a higher priority than SessionVeriable.
57+
* This usually means that the cluster administrator force user restrictions.
58+
* Users cannot modify these SessionVeriables with the same name.
5359
*/
5460
public class UserProperty implements Writable {
61+
private static final Logger LOG = LogManager.getLogger(UserProperty.class);
5562
// advanced properties
5663
private static final String PROP_MAX_USER_CONNECTIONS = "max_user_connections";
5764
private static final String PROP_MAX_QUERY_INSTANCES = "max_query_instances";
@@ -172,6 +179,10 @@ public long getExecMemLimit() {
172179
}
173180

174181
public void update(List<Pair<String, String>> properties) throws UserException {
182+
update(properties, false);
183+
}
184+
185+
public void update(List<Pair<String, String>> properties, boolean isReplay) throws UserException {
175186
// copy
176187
long newMaxConn = this.commonProperties.getMaxConn();
177188
long newMaxQueryInstances = this.commonProperties.getMaxQueryInstances();
@@ -311,7 +322,14 @@ public void update(List<Pair<String, String>> properties) throws UserException {
311322
}
312323
workloadGroup = value;
313324
} else {
314-
throw new DdlException("Unknown user property(" + key + ")");
325+
if (isReplay) {
326+
// After using SET PROPERTY to modify the user property, if FE rolls back to a version without
327+
// this property, `Unknown user property` error will be reported when replay EditLog,
328+
// just ignore it.
329+
LOG.warn("Unknown user property(" + key + "), maybe FE rolled back version, Ignore it");
330+
} else {
331+
throw new DdlException("Unknown user property(" + key + ")");
332+
}
315333
}
316334
}
317335

fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ public void dropUser(UserIdentity userIdent) {
7272
}
7373
}
7474

75-
public void updateUserProperty(String user, List<Pair<String, String>> properties) throws UserException {
75+
public void updateUserProperty(String user, List<Pair<String, String>> properties, boolean isReplay)
76+
throws UserException {
7677
UserProperty property = propertyMap.get(user);
7778
if (property == null) {
7879
throw new DdlException("Unknown user(" + user + ")");
7980
}
8081

81-
property.update(properties);
82+
property.update(properties, isReplay);
8283
}
8384

8485
public int getQueryTimeout(String qualifiedUser) {

0 commit comments

Comments
 (0)