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. Let's first get an overview.
- Assistant
Great, found the file. Let's examine its content to understand the issue. First, let's see the directory structure around it.
- Assistant
Now I need to understand the issue better. The problem is that realtime triggers (like Kafka triggers) are being reported as locked/blocked by the
TriggerSchedulerMonitor.Looking at the monitor code:
- It retrieves all locked triggers using
triggerStateStore.findTriggersEligibleForScheduling(now, defaultScheduler.currentVNodesAssignment(), true) - For each trigger, it tries to find the execution associated with that trigger
- If no execution is found, it logs a warning: "No execution found, schedule is blocked since..."
The issue is that realtime triggers (like Kafka) don't have execution IDs in the same way scheduled triggers do. They are event-driven and don't follow the same lifecycle. When the monitor finds them in a "locked" state but without an execution, it incorrectly reports them as blocked.
Let me first look at how
findTriggersEligibleForSchedulingworks to understand what "locked" means in this context. Let me find the interface and implementation. - It retrieves all locked triggers using
- Assistant
Let me look at the
TriggerStateclass to understand what it represents. - Assistant
Let me look at the TriggerState class and the findAllByTrigger method to understand the issue better.
- Assistant
Now let me look at the
findAllByTriggermethod and theTriggerTypeenum. - Assistant
Let me examine the TriggerType to understand what types exist.
- Assistant
So there's
REALTIME,POLLING, andSCHEDULEtrigger types. The issue is thatTriggerSchedulerMonitoris fetching locked triggers (thetrueparameter infindTriggersEligibleForScheduling), and realtime triggers get locked as part of their normal operation. But since realtime triggers don't have an associated execution ID (they're event-driven, not execution-driven), the monitor logs them as "blocked".Let me understand how the scheduler handles realtime triggers. Let me look at how the scheduler interacts with realtime triggers.
- Assistant
Now let me look at the
findTriggersEligibleForSchedulingmethod to understand what it returns. Let me also check thefindAllByTriggermethod. - Assistant
Now let me understand the issue better. The issue is that realtime triggers (like Kafka triggers) are reported as locked by the
TriggerSchedulerMonitorbecause:- The
TriggerSchedulerMonitorqueries all locked triggers usingfindTriggersEligibleForScheduling(now, defaultScheduler.currentVNodesAssignment(), true) - For each trigger, it tries to find the associated execution via
executionRepository.findAllByTrigger(state) - For realtime triggers, there may never be an execution (or the execution might be transient)
- When no execution is found, it logs: "No execution found, schedule is blocked since..."
The key insight is that realtime triggers behave differently from scheduled triggers - they don't always have associated executions that are tracked in the same way. Let me look more at the realtime trigger implementation.
- The
- Assistant
The issue is clear now. The
TriggerSchedulerMonitoris looking at locked triggers (locked=trueinfindTriggersEligibleForScheduling) and for each locked trigger, it tries to find an associated execution. If no execution is found, it logs a warning.For realtime triggers, there's no execution associated with them - they just continuously listen for events. The
lockedflag on a realtime trigger simply means the trigger is currently active and assigned to a worker, not that it's waiting for an execution to complete.So the fix should be to exclude realtime triggers from the monitoring logic, since they don't have the concept of "blocked execution" - they're always "running" without an associated execution.
Let me check the
TriggerTypeenum to see if I can filter by trigger type. - Assistant
Let me look at how the scheduler handles realtime triggers to understand why they're reported as locked.
- Assistant
Let me look at how the TriggerScheduler handles realtime triggers - it should give us insight into the locking mechanism.
- Assistant
Let me look at the TriggerScheduler to understand how triggers are locked/unlocked.
- Assistant
Now I understand the issue clearly. Let me trace through the flow:
- In
TriggerScheduler.processWorkerTrigger(), for realtime triggers,mustBeLockedis alwaystrue, so the trigger is always locked after being sent to the worker. - The
TriggerSchedulerMonitormonitors all locked triggers and tries to find associated executions. - For realtime triggers, they are always locked (because they are continuously running on a worker), but there's no execution associated with them at the time the monitor checks.
- The monitor incorrectly reports these as "blocked" triggers.
The fix is to filter out realtime triggers from the
TriggerSchedulerMonitorsince they are always locked by design and don't have associated executions in the same way as schedule/polling triggers.Let me also check the test file for
TriggerSchedulerMonitor: - In
- Assistant
Let me also look at the tests for the scheduler to understand the test conventions:
- Assistant
Now let me look at how the
TriggerTypeis available on theTriggerStateobject: - Assistant
Good. Now I understand the issue clearly. The
TriggerSchedulerMonitorfetches all locked triggers and checks if there's an associated execution. For realtime triggers (like Kafka), they are always locked by design because they're continuously running on a worker, but there's no "current execution" to find since they produce executions only when events arrive. So the monitor incorrectly reports them as blocked.The fix is to filter out realtime triggers from the monitoring check. Let me implement this:
- Assistant
Now I understand the issue clearly. The
TriggerSchedulerMonitorfetches all locked triggers and tries to find the associated execution. For realtime triggers (like Kafka), they are always locked because they are continuously listening for events - they don't produce an execution record in the same way that schedule or polling triggers do. So the monitor incorrectly reports them as "blocked".The fix should filter out realtime triggers from the monitoring logic, since they are always locked by design and don't have the same execution lifecycle.
Let me implement the fix:
- Assistant
The file got messed up with duplicate imports. Let me rewrite it properly.
- Assistant
I need to fix the duplicate imports. Let me rewrite the file properly.
- Assistant
Let me verify the file looks correct:
- Assistant
Good. The fix is clean. Now let me verify the change compiles and check if there are any existing tests related to this:
- Assistant
No test files for TriggerSchedulerMonitor. Let me check if the project compiles. Let me look at the build system first:
- Assistant
Let me check if there are tests related to the scheduler:
- Assistant
Let me try to compile the scheduler module to ensure the changes are valid:
- Assistant
Good, compilation is successful. Let me run the existing scheduler tests:
- Assistant
All 75 tests pass. Let me verify the diff of my changes:
- Assistant
The diff looks clean and minimal. Let me now run the broader test suite to ensure nothing else breaks:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.