ISSUE DESCRIPTION The TriggerSchedulerMonitor reports realtime triggers as locked…
- User
ISSUE DESCRIPTION
The
TriggerSchedulerMonitorreports realtime triggers as lockedDescribe the issue
The
TriggerSchedulerMonitorreports realtime triggers as locked.[tenant: main] [namespace: company.team] [flow: realtime-kafka] [trigger: kafka] No execution found, schedule is blocked since '2026-04-27T13:38:23.415498Z'
But as those trigger will always be blocked without any executionID they will be reported indefinitly.
Environment
- Kestra Version: develop
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /kestra, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files related to
TriggerSchedulerMonitor. Let's begin with some basic navigation. - Assistant
Let me find the TriggerSchedulerMonitor class and understand the issue better.
- Assistant
Let me examine the TriggerSchedulerMonitor.java file to understand the issue.
- Assistant
Let me understand more about the trigger state and realtime triggers.
- Assistant
Let me look at the TriggerStateStore interface and its implementation to understand what
findTriggersEligibleForSchedulingreturns, particularly regarding realtime triggers. - Assistant
Let me look at the TriggerState class to understand its structure and what fields it has.
- Assistant
Let me look at the
TriggerTypeenum and understand what makes a trigger "realtime". - Assistant
Let me examine the TriggerType class to understand the difference between realtime and polling triggers.
- Assistant
Now let me look at how the realtime triggers are handled in the scheduler. Let me also check the
RealtimeTriggerInterface. - Assistant
Let me examine the CachedTriggerStateStore implementation to see how triggers are filtered.
- Assistant
Let me look at the JDBC implementation of
findTriggersEligibleForScheduling. - Assistant
Let me continue reading to find the
findTriggersEligibleForSchedulingmethod. - Assistant
Let me see around line 315.
- Assistant
Let me look at how realtime triggers are handled in the scheduler to understand the flow better.
- Assistant
Now I'm understanding the issue better. Let me look at the
TriggerSchedulerto understand how realtime triggers are scheduled and locked. - Assistant
Now I understand the issue. Let me look at the
TriggerState'stypefield and how realtime triggers behave. - Assistant
Now I understand the issue. The
TriggerSchedulerMonitorretrieves all locked triggers, but realtime triggers (like Kafka) are always locked because they're continuously running. The monitor then checks for executions for each trigger, but realtime triggers don't necessarily have an execution for every cycle, causing false "blocked" reports.Let me verify the flow by checking what
findAllByTriggerreturns. - Assistant
Let me check the
TriggerStateclass to see if there's a way to identify realtime triggers and understand the issue better. - Assistant
Now I understand the problem. The
TriggerSchedulerMonitorchecks all locked triggers. For realtime triggers (like Kafka), they are always locked (theprocessWorkerTriggermethod inTriggerSchedulersetslocked = truefor realtime triggers). When the monitor checks these realtime triggers, it looks for an execution usingfindAllByTrigger, but realtime triggers might not have an associated execution in the same way polling/schedule triggers do. So the monitor incorrectly reports them as "blocked" because it can't find an execution.Let me create a test to reproduce the issue first.
- Assistant
Let me check the
findAllByTriggermethod. - Assistant
Let me look at the Jdbc implementation to understand what findAllByTrigger does.
- Assistant
Now I understand the issue. The problem is:
- Realtime triggers (like Kafka) are always locked because
processWorkerTriggersetslocked = truefor realtime triggers. - The
TriggerSchedulerMonitorruns every 10 seconds and finds all locked triggers. - For each locked trigger, it tries to find an execution.
- For realtime triggers, there might not be any execution yet (or the trigger is waiting for events), so
findAllByTriggerreturns empty. - The monitor then reports "No execution found, schedule is blocked since..." which is a false positive for realtime triggers.
Let me check how to identify realtime triggers in the
TriggerStateorTriggerContext. - Realtime triggers (like Kafka) are always locked because
- Assistant
Let me check existing tests for the monitor.
- Assistant
The issue is clear now. The
TriggerSchedulerMonitormonitors locked triggers to detect when they are "blocked" (no execution found). For realtime triggers (like Kafka), they are always in a locked state (locked = true) because the process is always running waiting for events. However, realtime triggers don't always have an execution - they only create an execution when an event is received. So when checkingfindAllByTrigger, there won't be an execution for realtime triggers most of the time, and the monitor incorrectly reports them as "blocked."The fix should be to filter out realtime triggers from the monitoring since their locked state is a normal operational state, not an indication of being blocked.
Let me look at the existing tests for the scheduler and understand test conventions:
- Assistant
Let me look at how we can filter out realtime triggers. We need to check if there's a way to filter by trigger type in the
findTriggersEligibleForSchedulingmethod. - Assistant
Let me find the test InMemoryTriggerStateStore.
- Assistant
Now I understand the issue clearly. The
TriggerSchedulerMonitorruns every 10 seconds and finds all locked triggers. For realtime triggers (like Kafka), they are always in a locked state because they're continuously listening for events, and they don't necessarily have an execution associated with them. So the monitor keeps reporting them as "blocked" indefinitely.The fix should be to filter out realtime triggers from the monitoring in the
TriggerSchedulerMonitor.run()method. Let me implement this fix. - Assistant
Now I understand the issue. The
TriggerSchedulerMonitormonitors all locked triggers and looks for their executions. For realtime triggers (like Kafka), they are always in a locked state because they are continuously listening for events, and they don't necessarily produce an execution for each event. So the monitor incorrectly reports them as "blocked" because it can't find an execution.The fix should be to filter out realtime triggers from the monitoring. Let me check if the
TriggerState.typefield is properly available.Let me check how to identify realtime triggers in TriggerState.
- Assistant
Good, I can see that
TriggerStatehas atypefield ofTriggerType. Now I need to filter out realtime triggers from the monitoring. The fix should be to skip realtime triggers in theTriggerSchedulerMonitor.run()method since their locked state is a normal operational state.Let me implement the fix:
- Assistant
Good, the import was added. Now I need to add the filter to skip realtime triggers in the run() method. The fix should filter out realtime triggers before processing them. Let me modify the
triggers.forEachblock to skip realtime triggers. - Assistant
It seems there's a duplicate closing brace. Let me fix the file properly.
- Assistant
There's a duplicate closing brace at the end. Let me fix it.
- Assistant
Good, the file looks clean now. Let me verify the diff to make sure the changes are correct.
- Assistant
The diff looks good. The main change is:
- Added import for
TriggerType - Changed
triggers.forEach(state ->totriggers.stream().filter(state -> state.getType() != TriggerType.REALTIME).forEach(state ->
This filters out realtime triggers from the monitoring loop. Let me fix the missing blank line between imports and the annotation.
- Added import for
- Assistant
I introduced a duplicate @Singleton. Let me fix that.
- Assistant
Good, the file looks correct now. Let me verify the final diff.
- Assistant
Good, the diff looks correct. The key change is:
- Added import for
TriggerType - Changed
triggers.forEach(state ->totriggers.stream().filter(state -> state.getType() != TriggerType.REALTIME).forEach(state ->
This filters out realtime triggers from the monitoring loop since they are always locked by design and shouldn't be reported as "blocked" when there's no execution.
Now let me run the existing tests to make sure nothing is broken. Let me first check what build system is used.
- Added import for
- Assistant
Let me check if there are any tests in the scheduler module.
- Assistant
Let me verify the build compiles correctly.
- Assistant
The build compiles successfully. Let me run the scheduler tests to make sure nothing is broken.
- Assistant
All 75 tests pass. Let me verify the final state of the file one more time.
- Assistant
Now let me verify the full diff is clean:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.