From 6974498d9838e3455f741b4b015a1ab1de4778d0 Mon Sep 17 00:00:00 2001 From: YongGang Date: Wed, 17 Apr 2024 19:45:41 -0700 Subject: [PATCH] Improve error message when task fails before becoming ready (#16286) --- .../java/org/apache/druid/indexing/overlord/TaskQueue.java | 6 ++++-- .../org/apache/druid/indexing/overlord/TaskQueueTest.java | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java index a143b93e9ef..70a8869ee52 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java @@ -427,8 +427,10 @@ public class TaskQueue if (e instanceof MaxAllowedLocksExceededException) { errorMessage = e.getMessage(); } else { - errorMessage = "Failed while waiting for the task to be ready to run. " - + "See overlord logs for more details."; + errorMessage = StringUtils.format( + "Encountered error[%s] while waiting for task to be ready. See Overlord logs for more details.", + StringUtils.chop(e.getMessage(), 100) + ); } notifyStatus(task, TaskStatus.failure(task.getId(), errorMessage), errorMessage); continue; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueTest.java index d34cb62d57c..6125a4d73be 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueTest.java @@ -298,12 +298,13 @@ public class TaskQueueTest extends IngestionTestBase @Test public void testExceptionInIsReadyFailsTask() { + final String exceptionMsg = "isReady failure test"; final Task task = new TestTask("t1", Intervals.of("2021-01-01/P1D")) { @Override public boolean isReady(TaskActionClient taskActionClient) { - throw new RuntimeException("isReady failure test"); + throw new RuntimeException(exceptionMsg); } }; taskQueue.add(task); @@ -314,7 +315,7 @@ public class TaskQueueTest extends IngestionTestBase Assert.assertEquals(TaskState.FAILED, statusOptional.get().getStatusCode()); Assert.assertNotNull(statusOptional.get().getErrorMsg()); Assert.assertTrue( - statusOptional.get().getErrorMsg().startsWith("Failed while waiting for the task to be ready to run") + statusOptional.get().getErrorMsg().contains(exceptionMsg) ); }