From 57e4c7fbbae881b5c8efb8e0b9c279b02e6fe217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Osipiuk?= Date: Wed, 6 Nov 2024 15:26:22 +0100 Subject: [PATCH] Prevent IllegalArgumentException if no pending node acquires We could get java.lang.IllegalArgumentException: bound must be positive when pendingAcquires was empty --- .../faulttolerant/BinPackingNodeAllocatorService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/BinPackingNodeAllocatorService.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/BinPackingNodeAllocatorService.java index 4cfa5325a020..cb47793e101f 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/BinPackingNodeAllocatorService.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/BinPackingNodeAllocatorService.java @@ -18,6 +18,7 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; @@ -351,6 +352,10 @@ private Iterator pendingAcquiresIterator(Optional start .map(entry -> new QueryPendingAcquires(entry.getKey(), entry.getValue().iterator())) .collect(toCollection(ArrayList::new)); + if (iterators.isEmpty()) { + return ImmutableList.of().iterator(); + } + int startingIteratorIndex = 0; if (startingQueryId.isPresent()) { startingIteratorIndex = -1;