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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
Let me look for the
TriggerSchedulerMonitorclass.Assistant
Let me look at the file content.
Assistant
Now let me explore the trigger model to understand the structure.
Assistant
Let me look at the TriggerState class and findTriggersEligibleForScheduling to understand how the triggers are tracked.
Assistant
There's a
TriggerTypereferenced inTriggerState. Let me find that class.Assistant
Now I understand! The
TriggerStatehas atypefield that can beREALTIME,POLLING, orSCHEDULE. Let me look at thefindAllByTriggermethod and understand it.Assistant
Let me check for any existing tests of
TriggerSchedulerMonitor.Assistant
Let me look at how realtime triggers are evaluated/processed.
Assistant
Let me look at the trigger state store to understand what "locked" means for a realtime trigger:
Assistant
Let me look at how realtime triggers handle executions:
Assistant
Let me look for any related tests in the project:
Assistant
Now let me first reproduce the issue and understand the code flow better:
Assistant
Let me look at the in-memory trigger state store used in tests:
Assistant
Now let me look at the CachedTriggerStateStore to see how its findTriggersEligibleForScheduling method works.
Assistant
Now let me look at the JDBC implementation to confirm locked realtime triggers are returned.
Assistant
Let me understand the timing of realtime trigger locking:
Assistant
Let me look for when realtime triggers get unlocked:
Assistant
Let me look at NextEvaluationDate.get() for realtime triggers:
Assistant
Let me look at
Logs.logTriggerto understand what's being logged:Assistant
Now I have a clear understanding. The issue is:
- Realtime triggers get locked immediately (no execution created until worker fires)
- They have
nextEvaluationDate= "now" so they get re-evaluated constantly - The monitor constantly checks for an execution which doesn't exist
- Resulting in constant warnings
The cleanest fix is to skip realtime triggers in the "no execution found" branch since that's normal behavior for them. Let me look at the imports and existing patterns:
Assistant
Now I have a clear understanding. Let me create a script to verify the current behavior first:
Assistant
Now let me apply the fix to
TriggerSchedulerMonitor.java:Assistant
Let me now apply the fix to
TriggerSchedulerMonitor.java:Assistant
Now let me add the check for realtime triggers:
Assistant
I made a mistake. The
executionvariable is not defined yet when I check it. Let me refactor to be cleaner:Assistant
Let me improve the structure for readability:
Assistant
Let me verify the changes:
Assistant
Now let me verify the code compiles. Let me first check the project's build setup:
Assistant
Code compiled successfully. Now let me also verify the fix by writing a test scenario (without modifying any existing tests):
Assistant
Let me now write a test script to verify the behavior of the trigger:
Assistant
Now let me also verify my fix by running the existing scheduler tests:
Assistant
Existing tests pass. Now let me run the TriggerSchedulerTest:
Assistant
All tests pass. Let me also run all scheduler tests:
Assistant
All 75 scheduler tests pass. Now let me create a small verification script (not a test file, just a temporary script) to verify the fix works for both polling and realtime triggers:
Assistant
Let me look at where realtime triggers are skipped similarly elsewhere in the codebase:
Assistant
Let me also verify the fix logic is correct by running a real test using the test infrastructure:
Assistant
Let me clean up the temp files I created:
Assistant
Let me search for any end-to-end tests that might exist for the trigger scheduler monitor:
Assistant
Let me run all tests in the scheduler module:
Assistant
Let me look at the diff of my changes:
Assistant
Let me also check the JDBC tests for TriggerRepository since they reference how trigger states are processed:
Assistant
The abstract test class doesn't have direct tests. Let me check jdbc-h2 tests as they would have the concrete implementations.
Assistant
Let me view the final file one more time to make sure it's correct:
Assistant
Let me run the tests one more time to ensure everything works correctly:
Assistant
Let me verify the final state with git diff:
Assistant
Let me also do a final verification by ensuring my understanding by checking the Final tests pass and the file is correctly modified:
Assistant
Now let me review my checklist:
Checklist:
-
✅ If an error was reported in the issue description, I have successfully reproduced it. - The issue was about incorrect logging behavior (not a runtime error). I traced the code path and understood the root cause: when a realtime trigger is locked waiting for events, the monitor logs a warning "No execution found, schedule is blocked since..." every 10s (the monitor's
fixedDelay), indefinitely. This matches the issue description.
-
Assistant
Let me view 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.