Conversation
hellolittlej
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
A Mantis worker with
Subscription-Timeout: 30sdid not shut down after losing all SSE sink connections. Investigation revealed two chained bugs:durationType: Transient(from job SLA) is lost during scheduling and hardcoded toPerpetualSummary
Workers configured with
Subscription-Timeoutdon't shut down after losing SSE sink connections becausedurationTypeis hardcoded toPerpetualin the scheduling path, regardless of job SLA configuration.One Chained Bugs
Bug 1 (scheduling):
TaskExecutorAllocationRequest.of()hardcodesMantisJobDurationType.Perpetual(line 42), ignoring the job's actual durationType. When jobs are scheduled through theExecutorStateManagerActor→AssignmentHandlerActorpath, theExecuteStageRequestFactory.of(TaskExecutorRegistration, TaskExecutorAllocationRequest)overload reads this hardcoded value. The TODO on line 34 acknowledges this://TODO: update job actor to fill these fields.Scheduling path:
Not a Bug: (worker-side consequence):
[This behavior is by design]
For Perpetual jobs,
SinkPublishercreates an eager subscription on a.share()'d Observable:When SSE clients disconnect,
ObservableTrigger.ssetrigger.doOnStopunsubscribes fromo, but the eager subscription keeps refCount >= 1. ThedoOnUnsubscribecallback (which would notifySubscriptionStateHandlerImpl) never fires. The handler stays insubscribed=truestate and never triggers the kill.Log Evidence
The log shows
durationType: Transientin the API butPerpetualat runtime:"sla": { "durationType": "Transient", ... }"eagerSubscription subscribed for Perpetual job."Key Files
TaskExecutorAllocationRequest.javadurationType=Perpetualinof()factoryAssignmentHandlerActor.java:109executeStageRequestFactory.of(registration, allocationRequest)with hardcoded PerpetualExecuteStageRequestFactory.javaof()overloads; theTaskExecutorAllocationRequestone reads the wrong durationTypeSinkPublisher.java:89-113.share()preventsdoOnUnsubscribefrom firingSubscriptionStateHandlerImpl.javaObservableTrigger.java:148-153ssetrigger.doOnStopcorrectly unsubscribes, but eager sub keeps refCount > 0Changes
1.
TaskExecutorAllocationRequest.javaPath:
mantis-control-plane/mantis-control-plane-core/src/main/java/io/mantisrx/server/master/resourcecluster/TaskExecutorAllocationRequest.javaAdd
durationTypeparameter to theof()factory method:2.
ResourceClusterAwareSchedulerActor.javaPath:
mantis-control-plane/mantis-control-plane-server/src/main/java/io/mantisrx/server/master/scheduler/ResourceClusterAwareSchedulerActor.java3. Update tests
Path:
mantis-control-plane/mantis-control-plane-server/src/test/java/io/mantisrx/master/resourcecluster/AssignmentHandlerActorTest.javaTaskExecutorAllocationRequest.of()calls to pass durationTypePath:
mantis-control-plane/mantis-control-plane-server/src/test/java/io/mantisrx/master/resourcecluster/ResourceClusterActorClusterUsageAkkaTest.javaTaskExecutorAllocationRequest.of()calls