Timeout after 10s when querying a workflow

Hi,

I have a workflow that can be simplified as follows.

func QueryWorkflow(ctx workflow.Context) error {
	queryResult := "started"
	logger := workflow.GetLogger(ctx)
	logger.Info("QueryWorkflow started")
	// setup query handler for query type "state"
	err := workflow.SetQueryHandler(ctx, "state", func(input []byte) (string, error) {
		return queryResult, nil
	})
	if err != nil {
		logger.Info("SetQueryHandler failed: " + err.Error())
		return err
	}

	queryResult = "something"
	// to simulate workflow been blocked on something, in reality, workflow could wait on anything like activity, signal or timer
	for {
                selector := workflow.NewSelector(ctx)
                selector.AddReceive(someChannel, func(c workflow.ReceiveChannel, _ bool) {
                       // update queryResult
                       // check other logic whether shouldStop
                 })
                
                selector.Select(ctx)
                
                if shouldStop {				
                       break
                 }

         }
	return nil
}

When I query the status of the variable, I often get a timeout at 10s.
I have done some searching but cannot find any relevant answer.
Can anybody help me shed some light on this, please? Thanks a lot.

That does seem strange. If the worker is not overloaded, it should handle the query without issue. Also check logs.

It seems like your code sample is close to runnable but not quite. Can you replicate with a full runnable sample so we can debug?

Thanks for your prompt response. Sure. Let me try.

Anyway, does the 10s ring any bell for you? It’s quite strange that it always stops at 10s.
Our API handling always has a timeout limit at 32s.

Btw, it doesn’t happen always. Around 4.5% of our queries got this issue.
Our SDK versions are as follows
go.temporal.io/sdk 1.13.1
go.temporal.io/api 1.7.0

It can, but I am afraid to speculate too much. For instance, that’s the default workflow task timeout which could mean your worker is not returning from a received query within that time. This would be a sign of an overloaded worker. But it’s a timeout that could occur in other places too.

1 Like

What happens if that workflow somehow has an Activity lasting more than 10s.
Will it also prevent the worker from answering the query?

No. A workflow running an activity will not prevent a query.

1 Like

Actually @Huong_Pham, my apologies, local activities can delay queries.

1 Like