This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-9441-cbecda473820b3b77f8e2a0fcb045a43d1fecfb7 in repository https://gitbox.apache.org/repos/asf/texera.git
commit 4ba907ea6574a889d8d6c8282ff766486c61ddb5 Author: Matthew B. <[email protected]> AuthorDate: Sun Nov 15 13:26:03 2026 +0000 perf(computing-unit): skip per-user unit fetch on local CU create (#9441) ### What changes were proposed in this PR? - ComputingUnitManagingResource.createWorkflowComputingUnit no longer calls wcDao.fetchByUid on every create; the lookup moves inside the Kubernetes branch, the only place its result is used (the per-user quota check). - That quota check counts running units with .count instead of building and sizing a filtered list. - Creating a local unit, the only type the single-node deployment offers, no longer issues the wasted per-user query. ### Any related issues, documentation, discussions? Closes: #9436 ### How was this PR tested? - Run `sbt "ComputingUnitManagingService/testOnly *ComputingUnitManagingResourceSpec"` and confirm it passes; the create path is behavior-preserving for the local unit case. - On the single-node stack, call POST /api/computing-unit and confirm a local unit is still created and returned as before. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF --- .../resource/ComputingUnitManagingResource.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala b/computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala index afd05e1aee..dbcb1e7e20 100644 --- a/computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala +++ b/computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala @@ -680,15 +680,15 @@ class ComputingUnitManagingResource( withTransaction(context) { ctx => val wcDao = new WorkflowComputingUnitDao(ctx.configuration()) - val units = wcDao - .fetchByUid(user.getUid) - .asScala - .filter(_.getTerminateTime == null) // Filter out terminated units - - if ( - units.size >= maxNumOfRunningComputingUnitsPerUser && cuType == WorkflowComputingUnitTypeEnum.kubernetes - ) { - throw InsufficientComputingUnitQuota(maxNumOfRunningComputingUnitsPerUser) + // Only Kubernetes units are quota-limited; skip the per-user lookup for local units. + if (cuType == WorkflowComputingUnitTypeEnum.kubernetes) { + val runningUnits = wcDao + .fetchByUid(user.getUid) + .asScala + .count(_.getTerminateTime == null) + if (runningUnits >= maxNumOfRunningComputingUnitsPerUser) { + throw InsufficientComputingUnitQuota(maxNumOfRunningComputingUnitsPerUser) + } } val resourceJson: String = cuType match {
