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 the
TriggerSchedulerMonitormentioned in the issue. Let's first get an overview. - Assistant
Let me find the TriggerSchedulerMonitor class.
- Assistant
Let me read the TriggerSchedulerMonitor class to understand the issue.
- Assistant
Now I need to understand the issue. The problem is that realtime triggers (like Kafka triggers) are being reported as locked by the
TriggerSchedulerMonitor, but they will always be "blocked" without any executionID, so they get reported indefinitely.Let me understand what a "realtime" trigger is vs a regular trigger, and how the
TriggerStatetracks them. Let me look at theTriggerStateand related models. - Assistant
Let me look at the TriggerState model to understand the fields.
- Assistant
Let me understand the
TriggerTypeenum and how realtime triggers are defined. - Assistant
Let me search for TriggerType as it's used in the TriggerState class.
- Assistant
Let me check the TriggerType enum and how realtime triggers are differentiated.
- Assistant
Now I understand the issue. The
TriggerSchedulerMonitorchecks for locked triggers and reports them as blocked if no execution is found. But for realtime triggers (like Kafka triggers), they are always locked without an execution ID, which means the monitor will report them indefinitely as blocked.Let me look at how the monitor queries for locked triggers and understand the flow better.
- Assistant
Let me look at the
findTriggersEligibleForSchedulingmethod in the TriggerStateStore interface and its implementation. - Assistant
Now let me look at the
RealtimeTriggerInterfaceand understand how realtime triggers work. - Assistant
Let me understand the issue better. The
TriggerSchedulerMonitoris monitoring "locked" triggers. When it finds a locked trigger, it checks if there's an associated execution. If no execution is found, it reports that the schedule is blocked.The issue says that realtime triggers (like Kafka triggers) are being reported as locked and blocked, but since they don't have execution IDs (they're realtime triggers, not polling triggers), they will always be reported as blocked indefinitely.
Let me look at the flow to understand this better. The
findTriggersEligibleForSchedulingwithlocked=truereturns triggers that are locked. For realtime triggers, they would be locked when they are being processed by a worker. But the monitor doesn't distinguish between realtime triggers and polling triggers when reporting.Let me understand the logic better by looking at the
findAllByTriggermethod and how executions relate to trigger states. - Assistant
Let me look at how realtime triggers are locked and how they differ from polling triggers.
- Assistant
Now let me look at the
findAllByTriggermethod to understand how it finds executions. - Assistant
Let me look at the
ExecutionRepositoryInterfaceto understand thefindAllByTriggermethod: - Assistant
Now I understand the issue. Let me look at how realtime triggers get locked in the scheduler:
- Assistant
Now I understand the issue. The
TriggerSchedulerMonitormonitors locked triggers and warns when there's no execution found for a locked trigger. This is meant for regular polling/scheduled triggers where a lock indicates an in-progress execution.However, for realtime triggers (like Kafka triggers), they are always locked (
locked(clock, true)) because realtime triggers continuously receive data and don't follow the normal lock/unlock pattern. They don't necessarily have an execution associated with them at any given point, so the monitor will always report them as "blocked" since no execution will be found.The fix should be to skip realtime triggers in the monitor. Looking at the
TriggerTypeenum, there's aREALTIMEtype. TheTriggerStatehas atypefield that should beREALTIMEfor realtime triggers.Let me verify by looking at how the trigger type is set.
- Assistant
Let me also check if there are tests for the TriggerSchedulerMonitor:
- Assistant
Now let me check if there's a test for the monitor. Let me search for test files related to it.
- Assistant
Now I have a clear understanding of the issue. Let me trace the full picture:
- In
processWorkerTrigger, realtime triggers getlocked(clock, true)always (becausemustBeLocked = trigger instanceof RealtimeTriggerInterface). - The
TriggerSchedulerMonitorretrieves all locked triggers and checks if there's an associated execution for each. - For realtime triggers, they will always be locked without necessarily having a corresponding execution, so the monitor keeps reporting them as "blocked" indefinitely.
The fix should filter out realtime triggers in the
TriggerSchedulerMonitor, since their locked state is expected behavior (they run continuously on a worker) and they don't follow the same execution lifecycle as polling/scheduling triggers.Let me check what
typefield is available inTriggerState: - In
- Assistant
Now let me check the test files to understand the testing structure:
- Assistant
Now let me look at the existing tests to understand how the test setup works:
- Assistant
Let me check if there are any existing tests specifically for the monitor:
- Assistant
Now let me look at how the
TriggerEventHandlerhandles the unlock logic to understand the complete picture: - Assistant
Now I have a clear understanding of the issue. Let me analyze it:
-
TriggerSchedulerMonitormonitors locked triggers by callingtriggerStateStore.findTriggersEligibleForScheduling(now, defaultScheduler.currentVNodesAssignment(), true)(thetrueparameter means locked triggers). -
For each locked trigger, it tries to find an execution using
executionRepository.findAllByTrigger(state). -
If no execution is found and the trigger has been locked for more than 60 seconds, it logs a warning: "No execution found, schedule is blocked since '...'".
-
The problem is with realtime triggers (like Kafka triggers). These triggers are always locked (
mustBeLocked = trigger instanceof RealtimeTriggerInterface || !((AbstractTrigger) trigger).isAllowConcurrent()), but they don't create executions in the same way as polling triggers. Realtime triggers work by continuously listening for events and creating executions when events arrive. They don't have an associated execution while they're just listening.
-
- Assistant
Now I understand the issue clearly. The
TriggerSchedulerMonitormonitors locked triggers and reports when no execution is found. However, for realtime triggers (like Kafka), they are always locked while running becauseprocessWorkerTrigger()setslocked(clock, mustBeLocked)wheremustBeLocked = trigger instanceof RealtimeTriggerInterfaceis alwaystrue. But realtime triggers don't always have an active execution - they listen for events continuously.The fix should be to filter out realtime triggers from the monitoring since they are expected to be locked while running, and they don't follow the same lock/unlock pattern as polling/schedule triggers.
Let me implement the fix:
- Assistant
Now I understand the fix needed. I need to:
- Import
TriggerType - Filter out realtime triggers from the monitoring, since they are always locked (they continuously listen for events) and don't have associated executions like polling/schedule triggers do.
Let me implement the fix:
- Import
- Assistant
Now I need to add the filter to skip realtime triggers. I'll add a filter after retrieving the triggers:
- Assistant
I see there's a duplicate opening brace on line 66. Let me fix that:
- Assistant
The file looks good. Let me verify the syntax by checking the file structure:
- Assistant
The file looks good. Now let me verify that the existing tests pass to make sure I haven't broken anything:
- Assistant
Let me try again with proper syntax.
- Assistant
No pom.xml at root level. Let me check the build system.
- Assistant
The project uses Gradle. Let me run the tests for the scheduler module to verify my changes don't break anything:
- Assistant
All 75 tests pass. Let me also check if there's a case where the
typecould be null and make sure the filter handles it correctly: - Assistant
The fix looks correct. The
TriggerType.REALTIME != state.getType()pattern is safe - ifstate.getType()is null (for some older trigger state), the comparison returnstruemeaning we'll still monitor it, which is correct behavior. TheTriggerEventHandleruses.equals()for a similar pattern which is also fine.Let me now review the complete diff to confirm the change:
- Assistant
The fix is minimal and clean. Let me also run a broader set of tests to ensure nothing else is broken:
- Assistant
The build succeeds. Let me now run the test one more time to make sure all tests pass:
- Assistant
Let me run the tests again and see the full output:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.