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 and finding the relevant files related to the
TriggerSchedulerMonitor.Assistant
Now let me understand the
TriggerStatemodel to see how to identify realtime triggers.Assistant
There's a
TriggerTypeenum. Let me look at it.Assistant
Now I understand the issue. The
TriggerSchedulerMonitorreports realtime triggers as locked/blocked, but realtime triggers will always be blocked without any executionID, so they will be reported indefinitely.The fix should skip realtime triggers in the monitor, since they don't have executions in the same way scheduled triggers do.
Let me look at the monitor more carefully. The monitor checks
findAllByTriggerfor each trigger. If there's no execution found and the trigger has been locked for more than 60 seconds, it logs a warning about the schedule being blocked.For realtime triggers, this check doesn't make sense because they're always "locked" (running/waiting for events) and won't have an execution until an event arrives. So the monitor should skip realtime triggers.
Let me look at the
TriggerStateto confirm it has agetType()method (which it does since it's a@Getterwith atypefield).Now let me check the
findTriggersEligibleForSchedulingto understand what triggers are returned.Assistant
Now let me look at the
findAllByTriggermethod in the ExecutionRepositoryInterface.Assistant
Let me look at the
RealtimeTriggerInterfaceto understand how realtime triggers work.Assistant
Now I understand the issue clearly. Realtime triggers are always "locked" while they wait for events. They produce executions only when events arrive. The
TriggerSchedulerMonitorchecks if there's an execution for each locked trigger, but for realtime triggers, this check doesn't make sense because they are always locked waiting for events and won't have executions until events arrive.Let me look at the test file for the monitor to understand the testing approach.
Assistant
Let me look at how realtime triggers are handled in the scheduler to understand the lock behavior.
Assistant
Now I have a clear understanding. The fix is to skip realtime triggers in the
TriggerSchedulerMonitor, since they are always locked while waiting for events and won't have executions until events arrive. Let me modify the monitor.Assistant
The
TriggerTypeis not imported in the monitor. Let me make the change.Looking at the run method:
javatriggers.forEach(state -> { Optional<Execution> execution = this.executionRepository.findAllByTrigger(state).next().blockOptional(); if (execution.isEmpty()) { ... if (state.getUpdatedAt() == null || state.getUpdatedAt().plusSeconds(60).isBefore(Instant.now())) { Logs.logTrigger( state, Level.WARN, "No execution found, schedule is blocked since '{}'", state.getUpdatedAt() ); } return; } ... });The fix should skip realtime triggers. The most logical place to do this is to filter the triggers list to exclude realtime triggers before processing, or to skip them inside the forEach loop.
Let me add a filter to exclude realtime triggers. I'll use the
TriggerType.REALTIMEcheck.Let me open the file and make the edit.
Assistant
Now let me make the changes. First, add the import for
TriggerType:Assistant
Now let me add the filter to exclude realtime triggers from the monitoring. The realtime triggers are always locked while waiting for events, so they would be reported as blocked indefinitely:
Assistant
Let me review the full file to make sure it looks correct:
Assistant
The change looks good. Now let me verify that the code compiles by checking the build system:
Assistant
It's a Gradle project. Let me compile the scheduler module to verify the change compiles correctly:
Assistant
The error seems to be about
TriggerStateStorenot being found, which is a pre-existing classpath issue. Let me check if this error exists without my change:Assistant
Without my change, the scheduler compiles fine. The previous error was likely because the core module wasn't compiled yet. Let me restore my changes and try again now that core is compiled:
Assistant
Let me check the imports more carefully - something might have gone wrong:
Assistant
I see the issue. When I added the
TriggerTypeimport, my edit accidentally replaced theTriggerStateStoreimport. Let me fix this:Assistant
Now let me compile again:
Assistant
The
Logsimport is also missing now. Let me check the full imports section:Assistant
The
import io.kestra.core.utils.Logs;is missing. Let me add it back:Assistant
Now the imports look correct. Let me compile again:
Assistant
The compilation succeeded (the only warning is a pre-existing one in
DefaultScheduler.java, unrelated to my change). Let me verify the final state of the file:Assistant
Now let me check if there are existing tests in the scheduler module that I should run to make sure nothing is broken:
Assistant
Test compilation succeeds with only pre-existing warnings. Let me run the existing scheduler tests to make sure nothing is broken:
Assistant
All tests pass. Let me also run the other scheduler tests to be thorough:
Assistant
All 75 tests pass. Let me review the final diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.