Issue with Get Workflow Execution History Request

I recently completed an execution of Worlflow.

From the web UI, this execution generated about 770 events, and the final end time was 2024-12-15T03:08:58.404989443Z.

In my java code, I need to get the execution result of each execution. After determining that my execution is over, I use the following code:


GetWorkflowExecutionHistoryRequest eventQuery = GetWorkflowExecutionHistoryRequest.newBuilder().setNamespace(temporalNamespace).setMaximumPageSize(5000).setExecution(execInfo.getExecution()).build();

GetWorkflowExecutionHistoryResponse history = temporalSvc.blockingStub().getWorkflowExecutionHistory(eventQuery);

to get all events of a single execution.

Although I set a pageSize of 5000, I still did not get all the events. The latest eventId is 573, and the eventTime is only 2024-12-15T02:23:41.958635093Z, which is 45 minutes earlier than the end time on the web ui.

I want to know if there is a caching policy in the history server, otherwise why can’t I get all the data at 03:08:59? Can anyone help me look into this issue? Thank you very much!

Make sure to paginate by using the pagination token. The service might limit the size of a single page below specified.

Just to add maybe, as Maxim mentioned,

.setMaximumPageSize(5000)

is going to be capped by service dynamic config limit.historyMaxPageSize which is by default 256. If you want to you can increase this dynamic config to larger number of and then use setMaximumPageSize if you need to set lower value than whats set in dynamic config.

If you dont want to have to paginate yourself, then instead of using

temporalSvc.blockingStub().getWorkflowExecutionHistory

use

client.fetchHistory

or

client.streamHistory

instead which does pagination for you (client is instance of your WorkflowClient)

Thanks @maxim @tihomir ,i change my way to use pagination token,now i do get all the events,thank you again!