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 the codebase.
Assistant
Now let me find the TriggerSchedulerMonitor class.
Assistant
Let me look at the TriggerState class to understand the structure and the flow with realtime triggers.
Assistant
Now let me look at the TriggerType class to understand the trigger types.
Assistant
Let me look at the TriggerStateStore to understand how triggers are found as locked.
Assistant
Now let me look at the MetricRegistry to understand the metrics.
Assistant
Now let me check the existing tests for TriggerSchedulerMonitor.
Assistant
Let me check the DefaultScheduler to understand how realtime triggers are handled.
Assistant
Let me look at the RealtimeTriggerInterface to understand what realtime triggers do.
Assistant
Let me check the
metricRegistry.tags(state)to understand it.Assistant
Now let me look at how the issue happens. Let me search the
findAllByTriggerfunction to understand how this check works.Assistant
Now let me look for how realtime triggers are handled in the worker.
Assistant
Let me look at the implementations of
findTriggersEligibleForScheduling.Assistant
Let me check the JDBC implementation for
findTriggersEligibleForScheduling.Assistant
Let me look at the realtime kafka trigger to understand how it gets locked.
Assistant
Let me search for "realtime" handling in the scheduler.
Assistant
Let me check the
findAllByTriggerquery.Assistant
Let me check how realtime trigger's execution is created.
Assistant
Let me check the
ExecutionTriggerclass and thetrigger_idfield.Assistant
Let me check the
Executionclass for thetrigger_idfield.Assistant
Let me check how
trigger_idis set in the executions table. Let me look for the JDBC mapping.Assistant
OK so it appears the
executionstable hastrigger_execution_idas a field, but no directtrigger_idcolumn. Let me look at the H2 database table for executions.Wait, let me re-read the query:
@Override public Flux<Execution> findAllByTrigger(TriggerId trigger) { var condition = field("trigger_id").eq(trigger.uid()); return findAsync(trigger.getTenantId(), condition); }It uses
trigger_idfield, which means it must be there. Let me look for it.Assistant
OK so I see. In the H2 database, the
executionstable does NOT have atrigger_idcolumn. It only hastrigger_execution_idfrom the JSONvaluefield'strigger.variables.executionId.In PostgreSQL, let me check that table:
Assistant
Let me find how the JdbcExecutionRepository actually queries with the
trigger_idcolumn.Assistant
Let me check the V2.0 upgrade migration file for executions table changes.
Assistant
Now I have a good understanding of the issue. Let me check the TriggerScheduler's
findTriggersEligibleForSchedulingfor realtime to confirm.Assistant
Let me look at the CachedTriggerStateStore to confirm.
Assistant
Let me investigate how realtime trigger's execution sets the triggerId. Let me look at where the trigger.id is set when creating an execution.
Assistant
Let me check what happens in the worker for realtime triggers.
Assistant
Let me look at
TriggerService.generateRealtimeEvaluationResultto see if trigger id is properly assigned.Assistant
Let me find the WorkerTriggerResult class.
Assistant
Let me check if the
trigger_idcolumn is on the executions table for the memory (test) implementation.Assistant
Now I have enough understanding to make the fix. The issue is that realtime triggers are always locked but don't have an execution that can be tracked via
findAllByTrigger. Let me make the fix to theTriggerSchedulerMonitor.Assistant
Now let me make the fix. The fix is to skip realtime triggers in the
TriggerSchedulerMonitorsince they are always locked but don't have an associated execution.Assistant
Let me fix the duplicate import I accidentally introduced:
Assistant
I have duplicates from the wrong edit. Let me rewrite the file from scratch with the fix.
Assistant
Let me verify the fix compiles by looking for any related tests.
Assistant
The compilation succeeded. Now let me write a test to verify the fix.
Assistant
Let me see the existing tests for related components.
Assistant
Let me check if there are existing tests for
TriggerSchedulerMonitor.Assistant
Let me create a temporary test file to verify my fix.
Assistant
The test passes. Let me also verify it would fail without my fix to ensure it's testing the right thing.
Assistant
Let me remove the temporary test file before submitting, as per the instructions.
Assistant
Now let me verify all the existing scheduler tests pass.
Assistant
All 75 existing tests pass. Let me verify the final state of the file.
Assistant
Let me make sure no other tests in the entire project that depend on TriggerSchedulerMonitor pass with the fix.
Assistant
Let me do a final review of my changes.
Assistant
Now let me create a quick reproduction script to verify the fix works in a more realistic scenario.
Assistant
Let me also verify that without my fix the test would fail. Let me temporarily revert and re-run:
Assistant
The test failed without my fix (confirming the issue) and passed with my fix. Let me verify the final state.
Assistant
Let me run the full test suite one more time to ensure nothing is broken.
Assistant
Let me verify that no test files have been left over.
Assistant
Let me do a final check on the file content:
Assistant
Now let me review the final state and ensure everything is good for submission.
Summary
Issue: The
TriggerSchedulerMonitorreports realtime triggers as locked with the message "No execution found, schedule is blocked since..." but realtime triggers are always locked by design (they are continuous streaming triggers), so this warning is reported indefinitely.Root Cause:
- In
TriggerScheduler.processWorkerTrigger(), realtime triggers are always locked (mustBeLocked = true). - The
TriggerSchedulerMonitoriterates through all locked triggers and tries to find an execution associated with each one. - For realtime triggers, there's no single execution associated with them that the monitor can track (they continuously emit executions, not a single one).
- This causes the monitor to report false-positive "blocked" warnings every 10 seconds.
Fix:
- In
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.