From 6fab88a3d10a2d6db8c8a45949fcd89ac607641a Mon Sep 17 00:00:00 2001 From: Imri Paran Date: Thu, 19 Dec 2024 14:03:01 +0100 Subject: [PATCH] fix(error-apps): reset apps in error state (#19052) --- .../service/apps/scheduler/AppScheduler.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java index 3163fc9a2e6..542edba0ccd 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/AppScheduler.java @@ -38,6 +38,7 @@ import org.quartz.Trigger; import org.quartz.TriggerBuilder; import org.quartz.TriggerKey; import org.quartz.impl.StdSchedulerFactory; +import org.quartz.impl.matchers.GroupMatcher; @Slf4j public class AppScheduler { @@ -93,10 +94,32 @@ public class AppScheduler { .getListenerManager() .addJobListener(new OmAppJobListener(dao), jobGroupEquals(APPS_JOB_GROUP)); + this.resetErrorTriggers(); + // Start Scheduler this.scheduler.start(); } + private void resetErrorTriggers() { + try { + scheduler + .getTriggerKeys(GroupMatcher.anyGroup()) + .forEach( + triggerKey -> { + try { + if (scheduler.getTriggerState(triggerKey) == Trigger.TriggerState.ERROR) { + LOG.info("Resetting trigger {} from error state", triggerKey); + scheduler.resetTriggerFromErrorState(triggerKey); + } + } catch (SchedulerException e) { + throw new RuntimeException(e); + } + }); + } catch (SchedulerException ex) { + LOG.error("Failed to reset failed triggers", ex); + } + } + public static void initialize( OpenMetadataApplicationConfig config, CollectionDAO dao, SearchRepository searchClient) throws SchedulerException {