Skip to content

Implement new task queue kind to send worker commands#9899

Merged
rkannan82 merged 29 commits intomainfrom
kannan/worker-commands-partition-metrics
Apr 20, 2026
Merged

Implement new task queue kind to send worker commands#9899
rkannan82 merged 29 commits intomainfrom
kannan/worker-commands-partition-metrics

Conversation

@rkannan82
Copy link
Copy Markdown
Contributor

@rkannan82 rkannan82 commented Apr 10, 2026

What

Add support for TASK_QUEUE_KIND_WORKER_COMMANDS in the matching service. This is a new task queue kind for server-to-worker communication (e.g. activity cancellations). It is represented by a new WorkerCommandsPartition type in the tqid package — analogous to how StickyPartition represents sticky queues.

Also adds a distinct partition metric tag for worker-commands queues so their traffic can be distinguished from user-facing normal queues in metrics.

Depends on #9900.

Why

Worker_Commands queue kind has different properties compared to a normal user defined queue. So we created a separate kind. This allows us to distinguish task queue metrics based on whether they are internal or user created queue.

How did you test it?

Unit tests covering metric tag generation for normal, sticky, and worker-commands partitions.

🤖 Generated with Claude Code

@rkannan82 rkannan82 requested review from a team as code owners April 10, 2026 00:59
@rkannan82 rkannan82 changed the title Add WorkerCommandsPartition type for metrics Add WorkerCommandsPartition type for worker-commands task queues Apr 10, 2026
@rkannan82 rkannan82 changed the title Add WorkerCommandsPartition type for worker-commands task queues Add TASK_QUEUE_KIND_WORKER_COMMANDS support Apr 10, 2026
Replace Kind() == STICKY checks with IsEphemeral() where the behavior
applies to all ephemeral partition types (sticky, and future types like
worker-commands), not just sticky queues specifically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from 6fd76ef to 872065b Compare April 10, 2026 04:02
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch 5 times, most recently from 7d9ffcf to a51f55b Compare April 10, 2026 04:25
@rkannan82 rkannan82 changed the base branch from main to kannan/ephemeral-partition-property April 10, 2026 04:26
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from a163283 to 2b99d6a Compare April 10, 2026 04:54
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from a51f55b to d3d045d Compare April 10, 2026 04:54
…ants

These are used in IsEphemeral() code paths that apply to all ephemeral
partition types, not just sticky queues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from 2b99d6a to 8e2ff4f Compare April 10, 2026 17:22
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from d3d045d to 6a515ee Compare April 10, 2026 17:22
@rkannan82 rkannan82 changed the title Add TASK_QUEUE_KIND_WORKER_COMMANDS support Implement new task queue kind to send worker commands Apr 12, 2026
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch 2 times, most recently from 81d28e9 to fb145ab Compare April 14, 2026 17:20
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch 2 times, most recently from a1a9cca to 994395c Compare April 14, 2026 22:49
Replace the single IsEphemeral() method on the Partition interface with
four specific property methods: HasTTLExpiry(), SupportsFairness(),
SupportsVersioning(), and SupportsPartitions(). Each call site now uses
the property that governs its behavior, making it clearer why a check
exists and easier to set correct values for new partition types.

PartitionCount() returns 1 when SupportsPartitions() is false, enforcing
the single-partition constraint explicitly.

Describe task queue checks use Kind() == NORMAL since only user-facing
queues can be described — this is about the queue's visibility, not a
specific property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from 994395c to 2a7094c Compare April 14, 2026 22:53
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from fb145ab to 5f7413c Compare April 14, 2026 23:00
rkannan82 and others added 4 commits April 15, 2026 14:29
The name field was always identical to taskQueue.Name() since
worker-commands queues have no separate identity like sticky queues do.
Add tests for PartitionFromProto with WORKER_COMMANDS kind and for
partition property methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s-partition-metrics

# Conflicts:
#	common/metrics/task_queues.go
#	common/tqid/task_queue_id.go
#	go.mod
#	go.sum
#	service/matching/db.go
#	service/matching/matching_engine.go
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 enabled auto-merge (squash) April 15, 2026 22:28
@rkannan82 rkannan82 disabled auto-merge April 15, 2026 22:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 requested a review from ShahabT April 16, 2026 00:01
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread common/tqid/task_queue_id.go
Comment thread common/tqid/task_queue_id.go Outdated
Comment thread common/tqid/task_queue_id.go
rkannan82 and others added 8 commits April 17, 2026 10:51
Co-authored-by: David Reiss <david@temporal.io>
The internal TaskQueuePartition proto's oneof doesn't have a
worker-commands variant yet. Add a TODO noting this gap for when
the admin RPCs need to support worker-commands partitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without this, loading a worker-commands partition manager would
panic in PersistenceName due to unhandled type switch case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test confirms that PersistenceName panics without the
WorkerCommandsPartition case (reproduced before fix). Also fixes
an unused variable from merge in UnsafePartitionFromProto.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update TestDispatchCancelToWorker to poll the control queue with
the correct Kind instead of NORMAL. This exercises the full
WorkerCommandsPartition code path through matching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add WorkerCommandsPartitionId empty message and use it as a new
variant in the TaskQueuePartition oneof, so internal RPCs can
represent worker-commands partitions. Handle the new variant in
PartitionFromPartitionProto. Also update the TaskQueuePartition
comment to describe it as the internal equivalent of the public
TaskQueue proto.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from 91fff51 to 34b0229 Compare April 18, 2026 00:02
@rkannan82 rkannan82 requested a review from dnr April 18, 2026 00:23
…s-partition-metrics

# Conflicts:
#	api/taskqueue/v1/message.pb.go
Comment thread proto/internal/temporal/server/api/taskqueue/v1/message.proto
@rkannan82 rkannan82 enabled auto-merge (squash) April 20, 2026 18:38
@rkannan82 rkannan82 merged commit 005d184 into main Apr 20, 2026
46 checks passed
@rkannan82 rkannan82 deleted the kannan/worker-commands-partition-metrics branch April 20, 2026 18:57
temporal-nick pushed a commit that referenced this pull request Apr 21, 2026
## What

Add support for `TASK_QUEUE_KIND_WORKER_COMMANDS` in the matching
service. This is a new task queue kind for server-to-worker
communication (e.g. activity cancellations). It is represented by a new
`WorkerCommandsPartition` type in the `tqid` package — analogous to how
`StickyPartition` represents sticky queues.

Also adds a distinct `partition` metric tag for worker-commands queues
so their traffic can be distinguished from user-facing normal queues in
metrics.

Depends on [#9900](#9900).

## Why

Worker_Commands queue kind has different properties compared to a normal
user defined queue. So we created a separate kind. This allows us to
distinguish task queue metrics based on whether they are internal or
user created queue.

## How did you test it?

Unit tests covering metric tag generation for normal, sticky, and
worker-commands partitions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: David Reiss <david@temporal.io>
rkannan82 added a commit that referenced this pull request May 1, 2026
## What

Use `TASK_QUEUE_KIND_WORKER_COMMANDS` enum check instead of string
prefix matching on the task queue to determine if its internal queue.

## Why

PR #9899 introduced `TASK_QUEUE_KIND_WORKER_COMMANDS`. The original code
(PR #9760) predated this and relied on the `/temporal-sys/` name prefix
as a workaround.

## How did you test it?

Existing tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants