Error: query directly though matching on non-sticky failed

We’re seeing a constant rate of this error from the history service for one specific workflow, and I’m not sure A) how we’re causing it and B) how to fix it. Any insight would be appreciated!

The workflow is running in an app called buoy and queried by a separate app called orca using the following code:

// workflowClientProvider is part of our own SDK to auto-handle XDC routing
val workflowClient = workflowClientProvider.get("namespace")

val stub = workflowClient.newWorkflowStub(,

// the query method that's having a bad time
return stub.nextStep

Additional information:

Temporal Server: 1.13.1
Java SDK: 1.7.1
error: context canceled
logging-call-at: historyEngine.go:941
service: history*zapLogger).Error

What’s the qps “orca” is sending to this workflow?
There have been some similar issues reported with too many queries sent to a single workflow, for example here.

Very low, it spikes to ~0.7 RPS, but average is 0.1 RPS:

I wouldn’t expect that this rate would cause problems.

Could you provide the error logged on historyEngine.go:941?

Also can you assure that the task queue used by the query still has worker(s) polling it? If there is, can you see if they are logging any errors?

The error logged was provided in the original post. Looks like the workflow had a bug which was making it generate ~1000 events per minute. Once we fixed that so that the event history wasn’t blowing up, these errors went away.

Hi @RobZienert can you share the solution which you applied to fix this ?

The developer had removed a Workflow.sleep that was being used to rate limit a while (true) { } call. Adding the sleep back restored the workflow to reasonable event rates.