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 find the relevant files related to the
TriggerSchedulerMonitor.Assistant
Found the file. Let me look at it.
Assistant
Now let me understand what a realtime trigger is and how it's distinguished from other triggers.
Assistant
Let me look at the
TriggerStatemodel and theTriggerStateStoreto understand the trigger state structure.Assistant
Now let me look at the
TriggerStateStoreto understandfindTriggersEligibleForScheduling.Assistant
Let me check the existing tests for the
TriggerSchedulerMonitorand look at how triggers are filtered.Assistant
Let me look at how realtime triggers are handled in the scheduler to understand the locking behavior.
Assistant
Now I understand the issue. Let me look at the
TriggerTypeenum and confirm how realtime triggers get locked. Let me also check the existing test structure for the scheduler.Assistant
Let me look at the realtime trigger test in
TriggerEventHandlerTest.javato understand the test patterns.Assistant
Now I understand the issue clearly. Realtime triggers are always locked when sent to a worker (see
processWorkerTrigger:final boolean mustBeLocked = trigger instanceof RealtimeTriggerInterface || ...). Since realtime triggers continuously evaluate waiting for events and don't necessarily produce executions, the monitor incorrectly reports them as "blocked" indefinitely.Let me open the monitor file and make the fix to exclude realtime triggers.
Assistant
Now I'll make the fix. I need to:
- Import
TriggerType. - Filter out realtime triggers since they're always locked while waiting for events and don't have the "blocked" semantics.
Let me first add the import for
TriggerType:- Import
Assistant
Now let me filter out realtime triggers from the list:
Assistant
Now let me verify the change compiles. Let me check the build system.
Assistant
The code compiles. Now let me look at the test infrastructure to understand how to write a reproduction test. Let me check the test stores and fixtures.
Assistant
Let me look at the
TriggerSchedulerTestto understand the test patterns, particularly around the execution repository and metric registry usage.Assistant
Let me look at the
DefaultSchedulerclass to understandcurrentVNodesAssignment().Assistant
Let me check the
ExecutionRepositoryInterface.findAllByTriggermethod signature.Assistant
Now let me write a reproduction test to verify the fix. Let me check the test dependencies available in the scheduler module.
Assistant
Mockito is available (used in
TriggerEventHandlerTest). Let me write a reproduction test that verifies the fix works. Let me first look at theTriggerEventHandlerTestsetup to mimic the patterns.Assistant
Let me check the
MetricRegistry.tagsmethod and thetimermethod signatures to properly mock them.Assistant
Let me check the
tags(TriggerState)- it doesn't exist directly butTriggerState implements TriggerId, so it would usetags(TriggerId triggerId). Let me check this method.Assistant
Now I'll write a reproduction test to verify the fix. Let me create a temporary test file.
Assistant
Let me verify the
TriggerId.ofmethod signatures to ensure correct usage.Assistant
Let me check the
SchedulerClockAPI to make sure I'm using it correctly.Assistant
Now let me run the reproduction test to verify the fix works.
Assistant
The verification is failing because the monitor passes the
TriggerStateobject (which implementsTriggerId) directly tofindAllByTrigger, not the originalTriggerId. Let me check theTriggerIdtype.Assistant
The issue is that the monitor passes the
TriggerStateobject tofindAllByTrigger, not the originalTriggerId. SinceTriggerStateandTriggerId.Defaultare different classes, they aren't equal. Let me fix the test using anArgumentCaptorto match by trigger id.Assistant
The
AssertionsForClassTypesimport doesn't support list assertions. Let me switch toAssertions.assertThat.Assistant
Both tests pass. Now let me verify that the test would have FAILED before my fix (to confirm the reproduction). Let me temporarily revert the fix.
Assistant
The reproduction confirms the issue: before the fix,
shouldNotReportRealtimeTriggerAsBlockedfails (the realtime trigger IS being checked and would be reported as blocked). After the fix, both tests pass.Now let me run the existing scheduler tests to make sure nothing is broken.
Assistant
All 77 tests pass (including my 2 reproduction tests). Let me check if there are any other places that report triggers as "blocked" that might need a similar fix.
Assistant
The only place that reports "schedule is blocked" and the missing-execution metric is the
TriggerSchedulerMonitor, which I've fixed. The fix also correctly avoids recording theMETRIC_SCHEDULER_EXECUTION_MISSING_DURATIONmetric for realtime triggers.Now let me remove the temporary reproduction test file since I shouldn't add new tests to the repository.
Assistant
Now let me review the final state of the changed file and verify the diff.
Assistant
Let me verify the final state of the file compiles and run the scheduler tests one final time.
Assistant
All 75 tests pass and the build is successful. Let me verify the final git status to confirm only the intended file is changed.
Assistant
Only the
TriggerSchedulerMonitor.javafile is modified, and the temporary test file has been removed. Let me do a final review of the complete file.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.