Skip to content

Set task poller type for scalable task pollers#2248

Open
kritibehl wants to merge 1 commit intotemporalio:mainfrom
kritibehl:fix-task-poller-type-2235
Open

Set task poller type for scalable task pollers#2248
kritibehl wants to merge 1 commit intotemporalio:mainfrom
kritibehl:fix-task-poller-type-2235

Conversation

@kritibehl
Copy link
Copy Markdown
Contributor

@kritibehl kritibehl commented Mar 23, 2026

What was changed

Updated newScalableTaskPoller(...) to accept and set scalableTaskPoller.taskPollerType and serverSupportsAutoscaling.

Wired poller types through when constructing scalable task pollers:

  • metrics.PollerTypeWorkflowTask for mixed and non-sticky workflow task pollers
  • metrics.PollerTypeWorkflowStickyTask for sticky workflow task pollers
  • metrics.PollerTypeActivityTask for activity task pollers
  • metrics.PollerTypeNexusTask for nexus task pollers
  • "" for local activity pollers (internal, not balanced)

Also restored serverSupportsAutoscaling threading through the constructor into newPollScalerReportHandle, fixed a formatting issue, and expanded test coverage with a table-driven test covering all poller types.

Why?

pollerBalancer uses scalableTaskPoller.taskPollerType to register and balance poller types, but that field was never being set. This change wires the poller type through at construction time so balancing can operate on the intended poller types.

Checklist

  1. Closes taskWorker.taskPollerType is not being set anywhere #2235
  2. How was this tested:
    • go test ./internal -run Poller
    • go test ./...
  3. Any docs updates needed?
    • No docs updates needed.

@kritibehl kritibehl requested a review from a team as a code owner March 23, 2026 20:50
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@kritibehl
Copy link
Copy Markdown
Contributor Author

Friendly follow-up: this fixes #2235 by wiring workflow poller type through scalable task poller construction and adds regression coverage for the assignment path. Happy to adjust if you’d prefer a different shape for the fix.

Comment thread internal/internal_nexus_worker.go Outdated
opts.executionParameters.Logger,
params.NexusTaskPollerBehavior,
params.serverSupportsAutoscaling),
params.NexusTaskPollerBehavior, ""),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should pass PollerTypeNexusTask it seems

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the latest push.

Comment thread internal/internal_worker.go Outdated
maxTaskPerSecond: params.WorkerActivitiesPerSecond,
taskPollers: []scalableTaskPoller{
newScalableTaskPoller(poller, params.Logger, params.ActivityTaskPollerBehavior, params.serverSupportsAutoscaling),
newScalableTaskPoller(poller, params.Logger, params.ActivityTaskPollerBehavior, ""),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And this PollerTypeActivityTask

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the latest push.

@kritibehl kritibehl force-pushed the fix-task-poller-type-2235 branch from ec8976a to f9bce07 Compare April 1, 2026 20:25
Copy link
Copy Markdown
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Left a few comments

maxPollerCount: p.maximumNumberOfPollers,
minPollerCount: p.minimumNumberOfPollers,
logger: logger,
serverSupportsAutoscaling: serverSupportsAutoscaling,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did we stop passing serverSupportsAutoscaling here? We still reference it in newPollScalerReportHandle(). I think this means autoscaling pollers can't sale down until they receive their first server scaling decision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored — it's now threaded through the constructor and into newPollScalerReportHandle.

Comment thread internal/internal_worker.go Outdated
localActivityWorker := newBaseWorker(baseWorkerOptions{
slotSupplier: laParams.Tuner.GetLocalActivitySlotSupplier(),
maxTaskPerSecond: laParams.WorkerLocalActivitiesPerSecond,
slotSupplier: laParams.Tuner.GetLocalActivitySlotSupplier(), maxTaskPerSecond: laParams.WorkerLocalActivitiesPerSecond,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These 2 lines got mashed into a single line, please separate them back into 2 lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, split back onto separate lines.

}
)

func (s *ScalableTaskPollerSuite) TestNewScalableTaskPollerSetsTaskPollerType() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we also include a test that verifies each poller type matches the poller (i.e. sticky workflow poller actually gets PollerTypeworkflowStickyTask) for each type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added TestNewScalableTaskPollerAllTypes covering workflow, sticky, activity and nexus types.

@kritibehl kritibehl force-pushed the fix-task-poller-type-2235 branch from f9bce07 to 48f0833 Compare April 2, 2026 01:20
@kritibehl
Copy link
Copy Markdown
Contributor Author

Friendly follow-up, I addressed the review comments and updated the branch, including the missing poller types, restored serverSupportsAutoscaling and added broader poller-type test coverage.

Happy to rebase or make any other adjustments if helpful. Thanks again for the review.

Copy link
Copy Markdown
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, was on vacation for a few weeks. Thanks for the contribution!

@kritibehl kritibehl force-pushed the fix-task-poller-type-2235 branch from 48f0833 to 0ef2a79 Compare April 28, 2026 19:17
@kritibehl
Copy link
Copy Markdown
Contributor Author

Thanks for the review and approval!

I rebased onto latest main, resolved the conflicts, and reran go test ./... locally after the rebase: all passing.

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.

taskWorker.taskPollerType is not being set anywhere

3 participants