Skip to content

[Scheduler] CountSchedules implementation for V1 and V2#9046

Merged
lina-temporal merged 8 commits intomainfrom
count-schedules
Jan 29, 2026
Merged

[Scheduler] CountSchedules implementation for V1 and V2#9046
lina-temporal merged 8 commits intomainfrom
count-schedules

Conversation

@lina-temporal
Copy link
Contributor

@lina-temporal lina-temporal commented Jan 15, 2026

What changed?

Why?

  • Our UI was previously using an undocumented ListWorkflowExecutions call to get a total count of schedules. This will allow us to move it to a public API in advance of CHASM release, which will continue to work for both V1 and V2.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

  • New API is highly symmetric in design to all other Count* APIs, and implementation is highly symmetric to ListSchedules. Seems low.

func (wh *WorkflowHandler) CountSchedules(
ctx context.Context,
request *workflowservice.CountSchedulesRequest,
) (_ *workflowservice.CountSchedulesResponse, retError error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of including the underscore here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because you need to name both arguments if you name one of them, and yet I never assign to the first return argument, so instead it is bound to "unused"/_.

Comment on lines 4612 to 4615
if wh.chasmSchedulerEnabled(ctx, namespaceName.String()) {
return wh.countSchedulesChasm(ctx, namespaceID, namespaceName, query)
}
return wh.countSchedulesWorkflow(ctx, namespaceID, namespaceName, query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing a pretty gradual rollout so there might be a significant amount of time where there is schedulers leftover on v1 stack. Once the flag is flipped for the namespace the count drops to 0 and increases as new schedules are created. Some time later, it increases as schedules wake up....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query itself we select with handles this case - VisibilityListQueryChasm will return results from both V1 and V2 scheduler, that'll apply to Count, as well.

I'll update the ListV1andV2 functional test to show this.

lina-temporal added a commit to temporalio/api that referenced this pull request Jan 28, 2026
**What changed?**
- Added a new CountSchedules API, symmetric to the other Count*
operations.

**Why?**
- Although it isn't documented as public API, the temporal UI makes use
of `ListWorkflowExecutions` to display the total count of schedules.
This operation will not return data for CHASM-based schedules.
Therefore, I'm introducing a public CountSchedules operation that the UI
(and customers) can make use of.

**Breaking changes**
- The technique of using `ListWorkflowExecutions` to query schedules was
always unsupported, so we aren't interested in supporting it for CHASM
schedules.
- `CountSchedules` will be implemented for both V1 and V2 schedules.

**Server**:
- [Server implementation
PR](temporalio/temporal#9046)
temporal-cicd bot pushed a commit to temporalio/api-go that referenced this pull request Jan 28, 2026
**What changed?**
- Added a new CountSchedules API, symmetric to the other Count*
operations.

**Why?**
- Although it isn't documented as public API, the temporal UI makes use
of `ListWorkflowExecutions` to display the total count of schedules.
This operation will not return data for CHASM-based schedules.
Therefore, I'm introducing a public CountSchedules operation that the UI
(and customers) can make use of.

**Breaking changes**
- The technique of using `ListWorkflowExecutions` to query schedules was
always unsupported, so we aren't interested in supporting it for CHASM
schedules.
- `CountSchedules` will be implemented for both V1 and V2 schedules.

**Server**:
- [Server implementation
PR](temporalio/temporal#9046)
@lina-temporal lina-temporal enabled auto-merge (squash) January 28, 2026 23:17
The CountSchedules API was added to the workflowservice but was missing
from the API metadata map and related test fixtures, causing unit test
failures.
Add Eventually helpers around query-filtered CountSchedules assertions
to handle potential visibility indexing latency on Cassandra+ES backends.
@lina-temporal lina-temporal merged commit 068dc97 into main Jan 29, 2026
66 checks passed
@lina-temporal lina-temporal deleted the count-schedules branch January 29, 2026 00:55
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.

2 participants