Skip to content

Commit 85371cc

Browse files
committed
fix replica
1 parent e8ceb5a commit 85371cc

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -212,41 +212,42 @@ private String getCurrentClusterId() throws ComputeGroupException {
212212
String cluster = null;
213213
ConnectContext context = ConnectContext.get();
214214
if (context != null) {
215-
if (!Strings.isNullOrEmpty(context.getSessionVariable().getCloudCluster())) {
216-
cluster = context.getSessionVariable().getCloudCluster();
215+
// TODO(wb) rethinking whether should update err status.
216+
cluster = context.getCloudCluster();
217+
218+
if (LOG.isDebugEnabled()) {
219+
LOG.debug("get compute group by context {}", cluster);
220+
}
221+
222+
if (context.getCurrentUserIdentity() != null) {
217223
try {
218224
((CloudEnv) Env.getCurrentEnv()).checkCloudClusterPriv(cluster);
219225
} catch (Exception e) {
220-
LOG.warn("get compute group by session context exception");
221-
throw new ComputeGroupException(String.format("session context compute group %s check auth failed",
222-
cluster),
223-
ComputeGroupException.FailedTypeEnum.CURRENT_USER_NO_AUTH_TO_USE_DEFAULT_COMPUTE_GROUP);
224-
}
225-
if (LOG.isDebugEnabled()) {
226-
LOG.debug("get compute group by session context compute group: {}", cluster);
227-
}
228-
} else {
229-
cluster = context.getCloudCluster(false);
230-
if (LOG.isDebugEnabled()) {
231-
LOG.debug("get compute group by context {}", cluster);
232-
}
233-
String clusterStatus = ((CloudSystemInfoService) Env.getCurrentSystemInfo())
234-
.getCloudStatusByName(cluster);
235-
if (!Strings.isNullOrEmpty(clusterStatus)
236-
&& Cloud.ClusterStatus.valueOf(clusterStatus)
237-
== Cloud.ClusterStatus.MANUAL_SHUTDOWN) {
238-
LOG.warn("auto start compute group {} in manual shutdown status", cluster);
226+
LOG.warn("check cloud cluster {} for {} auth failed.", cluster,
227+
context.getCurrentUserIdentity().toString());
239228
throw new ComputeGroupException(
229+
String.format("context compute group %s check auth failed, user is %s",
230+
cluster, context.getCurrentUserIdentity().toString()),
231+
ComputeGroupException.FailedTypeEnum.CURRENT_USER_NO_AUTH_TO_USE_DEFAULT_COMPUTE_GROUP);
232+
}
233+
}
234+
235+
String clusterStatus = ((CloudSystemInfoService) Env.getCurrentSystemInfo())
236+
.getCloudStatusByName(cluster);
237+
if (!Strings.isNullOrEmpty(clusterStatus)
238+
&& Cloud.ClusterStatus.valueOf(clusterStatus)
239+
== Cloud.ClusterStatus.MANUAL_SHUTDOWN) {
240+
LOG.warn("auto start compute group {} in manual shutdown status", cluster);
241+
throw new ComputeGroupException(
240242
String.format("The current compute group %s has been manually shutdown", cluster),
241243
ComputeGroupException.FailedTypeEnum.CURRENT_COMPUTE_GROUP_BEEN_MANUAL_SHUTDOWN);
242-
}
243244
}
244245
} else {
245246
if (LOG.isDebugEnabled()) {
246247
LOG.debug("connect context is null in getBackendId");
247248
}
248-
throw new ComputeGroupException("connect context not set",
249-
ComputeGroupException.FailedTypeEnum.CONNECT_CONTEXT_NOT_SET);
249+
throw new ComputeGroupException("connect context not set cluster ",
250+
ComputeGroupException.FailedTypeEnum.CONNECT_CONTEXT_NOT_SET);
250251
}
251252

252253
return getCloudClusterIdByName(cluster);

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/BackendDistributedPlanWorkerManager.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ private ImmutableMap<Long, Backend> checkAndInitClusterBackends(
8888
// 1 get compute group
8989
ComputeGroup cg = context.getComputeGroup();
9090

91-
// 2 load job has been checked priv when submitting task, so no need check priv here.
92-
if (!isLoadJob) {
93-
try {
94-
((CloudEnv) Env.getCurrentEnv()).checkCloudClusterPriv(cg.getName());
95-
} catch (Exception e) {
96-
LOG.warn("cluster priv check failed", e);
97-
throw new UserException("cluster priv check failed", e);
98-
}
91+
// 2 check priv
92+
try {
93+
((CloudEnv) Env.getCurrentEnv()).checkCloudClusterPriv(cg.getName());
94+
} catch (Exception e) {
95+
LOG.warn("cluster priv check failed", e);
96+
throw new UserException("cluster priv check failed", e);
9997
}
10098

10199
// 3 return be list

0 commit comments

Comments
 (0)