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
This is a Kestra repository. Let me explore the scheduler module since the issue is about
TriggerSchedulerMonitor.Assistant
Let me explore the
TriggerStateclass to understand what it contains.Assistant
Let me look at the
TriggerStateStoreto understandfindTriggersEligibleForScheduling.Assistant
Let me look at how realtime triggers work in the scheduler to understand them better.
Assistant
Now let me look at the
DefaultSchedulerclass to see how triggers are being locked and how this is being run.Assistant
Let me explore the
TriggerSchedulerclass.Assistant
Let me search for tests for TriggerSchedulerMonitor to understand the testing conventions.
Assistant
Let me also look at the worker-side handling for realtime triggers.
Assistant
Now let me look at the tests in the scheduler module to understand the testing patterns:
Assistant
Now I understand the issue clearly. Let me also check how realtime triggers store their state to make a proper fix:
Assistant
Now I have enough understanding. Let me look at the logs utility to understand how logging works in the project:
Assistant
Now let me make the fix. Looking again at the issue:
The issue is that the
TriggerSchedulerMonitorreports realtime triggers as "locked" because:- Realtime triggers get locked in the scheduler when sent to workers
- The monitor checks if there's an execution for a locked trigger
- For realtime triggers, there might not be an execution if there are no events (e.g., no Kafka events)
- The monitor then warns that "schedule is blocked"
We need to skip realtime triggers in this check, since it's normal for them to not have executions.
Assistant
Now I'll fix the issue by skipping realtime triggers in the monitor:
Assistant
Let me make the indentation fix and continue with the actual fix:
Assistant
Now I need to add the actual fix - skipping REALTIME triggers in the loop:
Assistant
I see there's an issue - I added an extra
{because the original was indented as a lambda block. Let me fix this properly:Assistant
Let me undo my changes and redo them more carefully:
Assistant
The file is getting messy with the edit. Let me revert the file and take a cleaner approach:
Assistant
Now let me make the change carefully without messing up the indentation:
Assistant
Let me make the changes more carefully. I'll just add a check at the start of the lambda:
Assistant
Now let me add the check at the start of the lambda body:
Assistant
Let me verify the changes look good:
Assistant
The diff looks clean. Let me now try to compile the scheduler module to ensure no compilation issues:
Assistant
Let me explore the existing tests to understand the test patterns used:
Assistant
Now let me look at the InMemoryTriggerStateStore so I can write a script to test my fix:
Assistant
Now let me check what relevant Mock files exist for ExecutionRepositoryInterface:
Assistant
Let me run the existing tests in the scheduler module to ensure they still pass:
Assistant
Now let me run all scheduler tests to make sure my change doesn't break anything:
Assistant
All 75 tests pass. Now let me create a temporary reproduction script to confirm the fix works correctly:
Assistant
Let me write a small reproduction script to verify the fix:
Assistant
Let me confirm the fix once more by examining the updated file:
Assistant
Let me look at one of the scheduler tests that does a setup similar to what we need:
Assistant
Let me create a temporary verification script to test the fix:
Assistant
Let me also check how
SchedulerClockis used in tests:Assistant
Let me check the
tags(TriggerState). Wait, it doesn't seem to be there. Let me check where it's used in TriggerSchedulerMonitor:Assistant
Hmm, it looks like
tags(state)does not exist exactly. ThemetricRegistry.tags(state)call would resolve totags(TriggerId). Let me check:Assistant
Let me confirm everything compiles correctly:
Assistant
Let me verify the final diff:
Assistant
Let me create a temporary Java test to verify the fix works:
Assistant
Let me write an actual integration test that mocks the dependencies. First, let me look at how the existing tests are constructed:
Assistant
Let me also check if there's a simpler test for
TriggerSchedulerMonitordirectly:Assistant
Let me verify the fix by viewing the final file content:
Assistant
Let me look at the directory structure to also confirm I'm not missing anything:
Assistant
Let me run all scheduler tests once more to confirm everything is OK:
Assistant
All tests passed. Now let me check the AGENTS.md to see if there are any specific guidelines I should follow:
Assistant
Let me also create a small temporary test to validate the fix - I'll write a simple program that doesn't require Micronaut testing setup:
Assistant
Let me clean up the temporary test:
Assistant
Now let me also verify the final state of the file:
Assistant
Let me run all the scheduler tests one final time:
Assistant
All 75 tests pass. Let me also check if there are tests that use
TriggerSchedulerMonitorin other modules:Assistant
Let me view the final state of the changes:
Assistant
The fix is minimal and surgical. Let me go over the checklist:
Checklist
- If an error was reported in the issue description, I have successfully reproduced it.
The issue was a logical/conceptual one (the monitor reporting realtime triggers as locked indefinitely). The code in
TriggerSchedulerMonitorwas indeed logging "schedule is blocked since '...'" for any locked trigger without an execution, including REALTIME triggers. We confirmed this through reading the code atscheduler/src/main/java/io/kestra/scheduler/TriggerSchedulerMonitor.java(therun()method) and atscheduler/src/main/java/io/kestra/scheduler/TriggerScheduler.java(theprocessWorkerTrigger()method which locks REALTIME triggers viamustBeLocked = true).- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
My fix adds a check at the start of the
triggers.forEachlambda to skip REALTIME triggers entirely. I verified this compiles (./gradlew :scheduler:compileJava) and all 75 scheduler tests pass.- I have thought about edge cases and made sure my fix handles them as well.
Edge cases considered:
- REALTIME triggers - Skipped as desired (the main fix).
- SCHEDULE triggers - Still monitored as before (correct - they should be monitored for blocked status).
- POLLING triggers - Still monitored as before (correct - they should be monitored for blocked status).
- Trigger with null type -
TriggerType.REALTIME.equals(state.getType())is null-safe (returns false when state.getType() is null), so it doesn't crash. - Locked REALTIME triggers that DO have an execution - Currently skipped (still no warning, since they would be skipped anyway). The schedule-locked-with-execution case shouldn't happen for REALTIME triggers because REALTIME triggers are kept locked by design (until they are deleted).
- Realtime triggers where the trigger state is partially populated - The check happens first, so any subsequent issues are avoided.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
I ran
./gradlew :scheduler:test --rerun-tasksand all 75 tests pass. The only file I changed isTriggerSchedulerMonitor.java, which had no existing tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →