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 to understand the codebase and locate the relevant files related to
TriggerSchedulerMonitorand realtime triggers. Let's first check the overall structure. - Assistant
Let me search for the
TriggerSchedulerMonitorclass to understand the issue. - Assistant
Let me examine the TriggerSchedulerMonitor file.
- Assistant
Let me understand the issue. The
TriggerSchedulerMonitoris reporting realtime triggers as locked, but realtime triggers don't have execution IDs, so they'll always appear as blocked.Let me look at the
findTriggersEligibleForSchedulingmethod to understand what it returns, and also understand what makes a trigger "realtime" vs scheduled. - Assistant
Let me understand the issue better. The
TriggerSchedulerMonitoris checking for "locked" triggers. It finds triggers that are "eligible for scheduling" and then checks if there's an associated execution. If no execution is found, it reports the trigger as blocked.The issue is that realtime triggers (like Kafka triggers) don't have execution IDs in the same way scheduled triggers do. A realtime trigger will always be "locked" without any executionID because it's waiting for external events, not scheduled executions.
Let me look at the relevant code to understand how realtime triggers work and how they differ from scheduled triggers.
- Assistant
Let me look at the TriggerState class to understand what a trigger state looks like.
- Assistant
Let me look at the TriggerState class to understand what information it holds, especially about whether a trigger is realtime or not.
- Assistant
Let me continue reading the file to understand the TriggerType field.
- Assistant
Let me look at the TriggerType to understand what types exist.
- Assistant
Let me look at the TriggerType to understand what types exist.
- Assistant
Now I understand the issue. The
TriggerSchedulerMonitoris reporting realtime triggers as locked when they don't have an associated execution. However, for realtime triggers (like Kafka), they are always "locked" waiting for external events, and they don't necessarily have an execution ID. The monitor is incorrectly treating them as problematic locked triggers.Let me look at the rest of the
TriggerState.javafile to understand more about how locked triggers work. - Assistant
Now I need to understand the issue:
TriggerSchedulerMonitorfinds triggers that are "locked" (i.e.,locked == true)- For realtime triggers, they are always locked while waiting for external events (like Kafka messages)
- The monitor checks if there's an execution associated with the locked trigger, and if not, reports it as blocked
- But realtime triggers don't have execution IDs in the same way - they're locked because they're actively waiting for events, not because an execution is stuck
The issue is that realtime triggers should not be checked for blocked state since their "locked" state is normal behavior - they're always locked while waiting for external events.
Let me look at the
TriggerStateclass to understand thetypefield and how to distinguish realtime triggers from other types. - Assistant
Now I see the issue clearly. The
TriggerSchedulerMonitorretrieves all locked triggers (line 56) and checks if there's an execution for each. For realtime triggers, they are always locked and don't necessarily have executions. The monitor should skip realtime triggers since being locked is their normal state. Let me check thefindAllByTriggermethod to understand how executions are found. - Assistant
Now I understand the problem. Let me look at the TriggerSchedulerMonitor more carefully:
findTriggersEligibleForScheduling(now, defaultScheduler.currentVNodesAssignment(), true)returns locked triggers- For realtime triggers, they are expected to be locked (waiting for events), but the monitor treats them the same as regular (polling/schedule) triggers
- Since realtime triggers don't have
executionIDin their state (or the execution lookup returns empty), the monitor logs a warning message about being blocked
The fix should be to skip realtime triggers in the
TriggerSchedulerMonitorbecause:- Realtime triggers are always locked while waiting for events
- They don't produce executions in the same way as polling/schedule triggers
- The blocked warning is misleading for them
Let me look at the
findAllByTriggermethod to understand what execution it returns. - Assistant
Now I understand the issue clearly. Let me check what information is available on the
TriggerStateto identify realtime triggers. TheTriggerStatehas atypefield that is of typeTriggerTypewhich can beREALTIME,POLLING, orSCHEDULE. The fix is to filter outREALTIMEtriggers from the monitor since they are expected to be locked without execution.Let me also check the
CachedTriggerStateStoreimplementation to understand thefindTriggersEligibleForSchedulingbehavior: - Assistant
Let me look at the
findAllByTriggermethod inExecutionRepositoryInterface: - Assistant
Now I understand the issue clearly. The
TriggerSchedulerMonitorruns periodically to check for locked triggers. It retrieves all locked triggers (line 56), then for each trigger it checks if there's an execution associated with it. If no execution is found, it logs a warning.The problem is that realtime triggers (like Kafka triggers) are always locked while waiting for events. They don't have executions in the same way polling/schedule triggers do. So the monitor incorrectly reports them as "blocked" when they're actually just waiting for events.
The fix should be to skip realtime triggers in the monitor. Let me check what the
TriggerStatetype field looks like and how to identify realtime triggers. I can see thatTriggerStatehas atypefield of typeTriggerTypewhich can beREALTIME,POLLING, orSCHEDULE.So the fix should be to filter out realtime triggers in the
TriggerSchedulerMonitor.run()method.Let me also check if there are any tests for this class.
- Assistant
Now I have a clear understanding of the issue. Let me implement the fix. The
TriggerSchedulerMonitor.run()method retrieves all locked triggers and checks for executions. For realtime triggers, they will always be locked without any execution since they are event-driven. The monitor should skip realtime triggers.Let me edit the file to filter out realtime triggers:
- Assistant
Now I'll make the fix. The
TriggerStatehas agetType()method that returnsTriggerType. I need to filter out realtime triggers from the monitoring loop. Let me add the import and filter: - Assistant
Now I need to add the filter for realtime triggers. Let me add a check to skip realtime triggers at the beginning of the forEach loop:
- Assistant
The edit command needs a different approach. Let me fix the missing blank line first.
- Assistant
Now I need to add the filter to skip realtime triggers. The
TriggerStatehas agetType()method that returnsTriggerType. I'll filter outREALTIMEtriggers in the forEach: - Assistant
I see there's a duplicate line 66 and 67. Let me fix that.
- Assistant
The file looks correct now. Let me verify the change is correct and then run tests. Let me first verify the full file:
- Assistant
The fix looks good. Now let me check if there are any tests related to the scheduler monitor:
- Assistant
No specific tests for
TriggerSchedulerMonitor. Let me check if there are any scheduler-related tests: - Assistant
Let me also verify that the
TriggerStateimplementsTriggerIdproperly (to make surefindAllByTrigger(state)works correctly): - Assistant
Good. Now let me verify
getType()method exists onTriggerState: - Assistant
Good - the
TriggerStateclass has atypefield and since it's annotated with@Getter, thegetType()method is generated by Lombok. Now let me check if there are any compilation issues by trying to compile: - Assistant
Let me check if there's a Gradle wrapper or build tool we can use.
- Assistant
Let me verify the code compiles by checking for any syntax issues. Let me also verify that the
TriggerType.REALTIMEreference is correct: - Assistant
Compilation is successful. Now let me run the scheduler tests to make sure I haven't broken anything:
- Assistant
All 75 tests pass. Let me verify the diff to make sure the changes are correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.