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
Now I need to understand the
TriggerStatemodel to identify realtime triggers.Assistant
Now let me look at the
findTriggersEligibleForSchedulingand understand how it differentiates between trigger types.Assistant
Now let me look at how realtime triggers work and check the realtime trigger fetcher.
Assistant
Let me check the DefaultScheduler to see how realtime triggers are added:
Assistant
Let me check more details on the trigger monitor and understand the existing tests for it.
Assistant
Let me look at the test for the TriggerStateStore:
Assistant
Let me look at the DefaultSchedulableTriggerFetcher:
Assistant
Let me check tests for understanding how the polling works:
Assistant
Let me look at the TriggerScheduler:
Assistant
Let me look at the NextEvaluationDate:
Assistant
Let me look at the
findAllByTriggermethod:Assistant
Now let me look at the tests for the monitor's scheduler:
Assistant
Let me search for where the realtime trigger lock is reset:
Assistant
Now I understand the issue clearly. Let me check the
TriggerState.getType()method:Assistant
Let me look at the metric registry to check if there are specific tags for REALTIME:
Assistant
Let me create a quick reproduction script to confirm my understanding:
Assistant
Now let me apply the fix to skip realtime triggers in the monitor since they don't have a 1:1 relationship with executions:
Assistant
Now let me apply the fix to skip realtime triggers:
Assistant
I accidentally duplicated the import. Let me fix that:
Assistant
Let me check the file more carefully:
Assistant
I see, there are two
import io.kestra.core.utils.Logs;now. Let me fix that.Assistant
Now let me add the actual logic to skip realtime triggers:
Assistant
I need to fix the indentation and closing braces:
Assistant
I see the catch block was removed accidentally. Let me fix that:
Assistant
Let me remove the extra trailing lines:
Assistant
Let me remove the placeholder reference:
Assistant
Now let me verify the file compiles by checking it with the Java compiler:
Assistant
The compilation succeeded. Let me view the full file one more time to verify the changes:
Assistant
Let me also handle the edge case where the type might be null:
Assistant
Let me check the existing tests in the scheduler module to understand the test patterns:
Assistant
Let me run the existing scheduler tests to ensure my changes don't break anything:
Assistant
All tests pass. Let me also check if there are tests that might be affected by this change:
Assistant
The only references to TriggerSchedulerMonitor are in its own file. There are no other tests depending on it.
Let me also verify there are no other places where
findTriggersEligibleForSchedulingis called withlocked=true. The only other place isTriggerSchedulerMonitor.run().Assistant
Let me also run the JDBC tests to make sure nothing else breaks:
Assistant
Let me run the JDBC tests related to TriggerRepository:
Assistant
Let me see if the TriggerSchedulingLoopTest has any tests for the monitor:
Assistant
Let me search for tests using the TriggerSchedulerMonitor indirectly:
Assistant
Let me create a quick reproduction script in Java to verify the fix works:
Assistant
Let me clean up the test file:
Assistant
Now let me check the final state of the file one more time:
Assistant
The diff looks clean. Let me view the final state of the file:
Assistant
Let me run the scheduler tests one more time to confirm everything still works:
Assistant
All 75 tests pass. Let me also run the JDBC-H2 tests:
Assistant
All 686 JDBC-H2 tests pass. Let me check the final diff:
Assistant
Let me also check the style used in other files to keep consistency:
Assistant
Let me rewrite the fix to match the existing code style in the codebase:
Assistant
I have some duplicates. Let me clean up properly:
Assistant
Let me reset the file to start with a clean state:
Assistant
Good, now the file is back to its original state. Let me apply the minimal change:
Assistant
Now the change is minimal and clean. Let me verify with compilation:
Assistant
All scheduler tests pass. Let me view the final diff:
Assistant
The final diff is minimal and focused. Let me go through the checklist:
-
Issue reproduced: I analyzed the code in
TriggerSchedulerMonitor.javaand confirmed the bug. Realtime triggers (like Kafka listeners) get locked when they're registered with a worker, but they don't have a 1:1 relationship with executions. When no external events come, no executions are created, but the monitor keeps reporting them as "blocked" indefinitely. -
Fix resolves the issue: The fix skips realtime triggers from the monitoring loop. Realtime triggers that have events will still create executions normally, and the lock will be reset when those executions terminate (via
TriggerExecutionTerminatedevent). The fix doesn't affect schedule or polling triggers. -
Edge cases handled:
state.getType()is null (legacy triggers or before the type was set): Handled by usingTriggerType.REALTIME.equals(state.getType())which is null-safe.- Schedule/Polling triggers: Still go through the normal logic.
- When realtime triggers do have executions, they go through the rest of the logic but the early return only happens at the start.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.