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
TriggerSchedulerMonitorthat's reporting realtime triggers as locked. Let's first get a sense of the structure. - Assistant
Let me find the TriggerSchedulerMonitor file first.
- Assistant
Let me look at the TriggerSchedulerMonitor file to understand the issue.
- Assistant
Now let me look at the
TriggerStateand related models to understand what a realtime trigger looks like: - Assistant
Let me search more broadly for TriggerState
- Assistant
Let me look at the TriggerState class and the TriggerStateStore to understand how triggers are managed.
- Assistant
Let me look at the TriggerType enum:
- Assistant
Let me check the TriggerType to understand the difference between realtime and scheduled triggers.
- Assistant
Let me look at the
findTriggersEligibleForSchedulingmethod: - Assistant
Let me look at how realtime triggers work to understand the issue:
- Assistant
Let me look at the scheduler to understand how realtime triggers are scheduled:
- Assistant
Let me look at the
findAllByTriggermethod in the execution repository: - Assistant
Now let me understand what
WorkerTriggerInterfaceandRealtimeTriggerInterfacelook like: - Assistant
Let me look at the execution repository to understand how it searches for executions by trigger:
- Assistant
Let me look at the
findTriggersEligibleForSchedulingmethod implementation to understand what triggers are returned: - Assistant
Let me look at the CachedTriggerStateStore to understand the implementation:
- Assistant
Now let me understand the full picture. Let me look at the existing tests for the monitor:
- Assistant
Now let me look at how realtime triggers are locked differently:
- Assistant
Now let me look at how
TriggerStatehas atypefield: - Assistant
Now let me look at how
findAllByTriggerworks: - Assistant
Now I understand the issue. For realtime triggers,
processWorkerTriggersetsmustBeLocked = true(sincetrigger instanceof RealtimeTriggerInterface), and the trigger state is saved withlocked(clock, mustBeLocked)=locked(clock, true). But realtime triggers don't necessarily have an associated execution immediately - they're waiting for events. The monitor assumes a locked trigger should have an execution, which isn't true for realtime triggers.Let me check how
TriggerStatehas atypefield and look at the issue from the monitor's perspective: - Assistant
Now I understand the issue. The
TriggerSchedulerMonitormonitors all locked triggers and tries to find executions for them. But for realtime triggers, they are always "locked" (becauseprocessWorkerTriggersetsmustBeLocked = trueforRealtimeTriggerInterface), and there might not be an execution because realtime triggers produce a stream of executions over time when events arrive. The monitor incorrectly reports them as "blocked" since there's no execution.Let me look at the DefaultScheduler to understand the context:
- Assistant
Now I understand the issue. The
TriggerSchedulerMonitormonitors all locked triggers and tries to find executions for them. But for realtime triggers, they're always locked and there may not be an execution associated with them since realtime triggers don't produce executions immediately (they wait for events). Let me look at the relevant part of the code to make the fix: - Assistant
Now I understand the issue clearly. Let me check how realtime triggers are scheduled:
- Assistant
Now I understand the issue. The
TriggerSchedulerMonitorchecks all locked triggers looking for their associated execution. For realtime triggers,mustBeLockedistrue, so they get locked after being sent to the worker. However, realtime triggers don't necessarily have a corresponding execution that matches the trigger state - they produce executions as events come in, so the monitor will never find an execution for them and will report them as blocked indefinitely.Let me check if there are tests for the monitor:
- Assistant
Now I understand the issue clearly. For realtime triggers,
mustBeLocked = trueis always set because they'reRealtimeTriggerInterface. The trigger gets locked after being sent to the worker, but realtime triggers don't create executions that match the trigger'sfindAllByTriggerlookup. They produce a stream of executions reactively as events come in, so there's no single execution to find. The monitor then reports them as blocked indefinitely.The fix should be to exclude realtime triggers from the monitoring check since they don't follow the same execution pattern. Let me check how to identify realtime triggers in the monitor:
- Assistant
Now I understand the issue clearly. The
TriggerSchedulerMonitorchecks all locked triggers and looks for associated executions. For realtime triggers, they are always locked (mustBeLocked = trueinprocessWorkerTrigger) but don't have a specific execution associated with them - they produce executions as events come in. So the monitor incorrectly reports them as blocked.The fix should be to exclude realtime triggers from the monitoring check since they don't follow the same execution pattern. Let me look at the
TriggerStatetype field and make the fix: - Assistant
Now I understand the issue. The
TriggerSchedulerMonitorchecks for locked triggers and tries to find an associated execution. For realtime triggers, they're always locked (becauseprocessWorkerTriggersetsmustBeLocked = truefor realtime triggers), but they don't have an associated execution in the repository because they produce executions as events come in. The monitor should skip realtime triggers.The
TriggerStatehas atypefield of typeTriggerTypewhich can beREALTIME. The fix is to filter out realtime triggers from the monitoring loop.Let me make the edit:
- Assistant
Let me use the edit command properly:
- Assistant
Let me try the edit command correctly:
- Assistant
Now I need to filter out realtime triggers from the monitoring. Let me add the filter after retrieving the triggers:
- Assistant
Now let me verify the full file:
- Assistant
Good. The fix looks correct. Now let me also verify that there are no other issues. Let me check if there are tests for this module:
- Assistant
Let me try to compile the scheduler module to make sure the code compiles:
- Assistant
The code compiles successfully. Now let me check if there are any existing tests related to the TriggerSchedulerMonitor:
- Assistant
Good - no tests for the monitor exist. Let me run the scheduler tests to make sure I haven't broken anything:
- Assistant
All 75 tests pass. Let me also verify the changes look correct with git diff:
- Assistant
Let me also verify the
getType()method exists onTriggerStateand there are no null safety concerns: - Assistant
Good - the field is
private final TriggerType typewith Lombok's@Getter, sogetType()is available. The fix looks correct.Let me now verify the full reasoning and approach:
-
Root Cause: In
TriggerScheduler.processWorkerTrigger(), realtime triggers always setlocked=true(mustBeLocked = trigger instanceof RealtimeTriggerInterface). TheTriggerSchedulerMonitorpicks up these locked triggers and looks for executions viaexecutionRepository.findAllByTrigger(state). However, for realtime triggers, there's no execution to find because realtime triggers don't produce executions that are linked to the trigger state in the same way scheduled/polling triggers do - they produce executions reactively as events come in. -
Fix: Filter out
TriggerType.REALTIMEtriggers from the monitoring loop, since they are inherently always locked and don't have associated executions to track.
Let me check one more thing - whether the
typefield can be null for backward compatibility: -
- Assistant
Good,
typeis not nullable. Let me also check whether there's a scenario wheretypecould benullfrom the store: - Assistant
Let me check if
typecould be null for existing triggers in the database (for backward compatibility): - Assistant
The fix looks correct. Let me also check if
typecould benullfrom deserialization (backward compatibility with existing data): - Assistant
Let me check if there could be null
typevalues. Since it's aprivate finalfield with Lombok's@Getter, and the constructors don't guard against null,typecould potentially be null. Butnull != TriggerType.REALTIMEevaluates totrue, so triggers with null type would still be monitored, which is the correct/safe behavior.Let me do one final verification of the changes:
- Assistant
The fix is minimal and correct. Let me now run the tests one final time and then submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.