Workflow history size / count exceeds limit
I'm trying to build a long-running process engine with Temporal, and the workflow structure is based on the official sample 'HelloSignal.java', like below:
while (!queryDataActivity.isFinished(projectId) || !actionQueue.isEmpty()) {
if (!Workflow.await(Duration.ofSeconds(10), () -> !actionQueue.isEmpty())) {
continue;
}
Action action = actionQueue.poll();
if (action instanceof ElementAction) {
elementActivity.doAction(projectId, (ElementAction) action);
}
if (action instanceof FlowAction) {
flowActivity.doAction(projectId, (FlowAction) action);
}
}
Recently I found my test workflow terminated unexpectedly several times. I downloaded workflow history and found theses logs from the tail of the history:
{ "eventId": "51200", "eventTime": { "seconds": "1607538963", "nanos": 697987657 }, "eventType": "EVENT_TYPE_WORKFLOW_TASK_STARTED", "version": "0", "taskId": "1188186", "workflowTaskStartedEventAttributes": { "scheduledEventId": "51199", "identity": "7148d862-ce0d-4642-b266-d21ee278f370", "requestId": "3b78c271-0d33-4ae4-89d4-dd6296d0477b" }, "attributes": "workflowTaskStartedEventAttributes" }, { "eventId": "51201", "eventTime": { "seconds": "1607538963", "nanos": 718118222 }, "eventType": "EVENT_TYPE_WORKFLOW_TASK_FAILED", "version": "0", "taskId": "1188189", "workflowTaskFailedEventAttributes": { "scheduledEventId": "51199", "startedEventId": "51200", "cause": "WORKFLOW_TASK_FAILED_CAUSE_FORCE_CLOSE_COMMAND", "identity": "history-service", "baseRunId": "", "newRunId": "", "forkEventVersion": "0", "binaryChecksum": "" }, "attributes": "workflowTaskFailedEventAttributes" }, { "eventId": "51202", "eventTime": { "seconds": "1607538963", "nanos": 718133178 }, "eventType": "EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED", "version": "0", "taskId": "1188191", "workflowExecutionTerminatedEventAttributes": { "reason": "Workflow history size / count exceeds limit.", "identity": "history-service" }, "attributes": "workflowExecutionTerminatedEventAttributes" }
It seems workflow history exceeds limit, so server force terminate the workflow ?
In my process engine, workflow is expected to running for years, now I reach the exceed limit within one day.
I wonder if there is any way to auto clear the log? or turn down the log level?
@doshide try using continue as new to reduce the history events length: https://docs.temporal.io/docs/go-continue-as-new
@wxing1292 make sense, thanks.
plz re-open the issue if there is further discussion