Skip to content

[Bug] temporal_worker_task_slots_used (sum across worker types) never reaches 0 during inter-activity gaps #1489

@Sanil2108

Description

@Sanil2108

What are you really trying to do?

We're using KEDA to autoscale Temporal Python SDK workers to zero replicas when no workflows are executing. We use temporal_worker_task_slots_used (summed across all worker types) as the KEDA composite metric trigger, expecting it to be 0 when the worker is idle.

Describe the bug

sum(temporal_worker_task_slots_used{task_queue="..."}) never drops to 0 even when no workflows are running

Minimal Reproduction

Start a Python SDK worker with any workflow that has ≥2 sequential activities
Scrape temporal_worker_task_slots_used at 15s intervals
Observe: WorkflowWorker slots = 1 during WFT scheduling between activity 1 completing and activity 2 starting — even though ActivityWorker = 0 at that exact moment
Sum across all worker_type values: the sum is always ≥1 while any workflow is in progress, including the inter-activity scheduling gaps

Environment/Versions

OS: Linux (Kubernetes, Python 3.13)
Temporal Server: self-hosted, version does not have worker_heartbeats capability (pre-1.27)
Python SDK: latest (temporalio with sdk-core at commit 2872b53)
Worker Deployment versioning: enabled (WorkerVersioningStrategy::WorkerDeploymentBased)
Deployment: Kubernetes with KEDA autoscaler, cooldownPeriod: 600s, activationTargetValue: 0

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions