From 22290d6d7559cb53b7b6bfc899cbe149993bcf01 Mon Sep 17 00:00:00 2001 From: zyyBjtu <20431508@qq.com> Date: Tue, 26 Sep 2023 11:15:11 +0800 Subject: [PATCH] Fix bug: when submitting tasks in batches, em resources may exceed the threshold --- .../service/impl/DefaultResourceManager.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/service/impl/DefaultResourceManager.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/service/impl/DefaultResourceManager.java index 672963e306..0023a38d95 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/service/impl/DefaultResourceManager.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/service/impl/DefaultResourceManager.java @@ -250,12 +250,14 @@ public ResultResource requestResource(List> labels, NodeResource resour CombinedLabel combinedLabel = labelContainer.getCombinedResourceLabel(); try { - // check ecm resource if not enough return + // lock userCreatorEngineTypeLabel + persistenceLocks.add( + tryLockOneLabel(combinedLabel, wait, labelContainer.getUserCreatorLabel().getUser())); try { - labelContainer.setCurrentLabel(emInstanceLabel); + labelContainer.setCurrentLabel(combinedLabel); if (!requestResourceService.canRequest(labelContainer, resource)) { return new NotEnoughResource( - String.format("Labels:%s not enough resource", emInstanceLabel.getStringValue())); + String.format("Labels:%s not enough resource", combinedLabel.getStringValue())); } } catch (RMWarnException exception) { return new NotEnoughResource(exception.getMessage()); @@ -263,14 +265,16 @@ public ResultResource requestResource(List> labels, NodeResource resour throw exception; } - // lock userCreatorEngineTypeLabel + // lock ecmLabel persistenceLocks.add( - tryLockOneLabel(combinedLabel, wait, labelContainer.getUserCreatorLabel().getUser())); + tryLockOneLabel(emInstanceLabel, wait, labelContainer.getUserCreatorLabel().getUser())); + + // check ecm resource if not enough return try { - labelContainer.setCurrentLabel(combinedLabel); + labelContainer.setCurrentLabel(emInstanceLabel); if (!requestResourceService.canRequest(labelContainer, resource)) { return new NotEnoughResource( - String.format("Labels:%s not enough resource", combinedLabel.getStringValue())); + String.format("Labels:%s not enough resource", emInstanceLabel.getStringValue())); } } catch (RMWarnException exception) { return new NotEnoughResource(exception.getMessage()); @@ -278,10 +282,6 @@ public ResultResource requestResource(List> labels, NodeResource resour throw exception; } - // lock ecmLabel - persistenceLocks.add( - tryLockOneLabel(emInstanceLabel, wait, labelContainer.getUserCreatorLabel().getUser())); - for (Label label : resourceLabels) { labelContainer.setCurrentLabel(label); NodeResource labelResource = labelResourceService.getLabelResource(label);