Skip to content

Commit aa9bfca

Browse files
committed
Fix execute workflow causing frequent context timeout (#484)
1 parent 0086b6f commit aa9bfca

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/main/java/com/uber/cadence/internal/common/WorkflowExecutionUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ private static CompletableFuture<HistoryEvent> getInstanceCloseEventAsync(
289289
request.setDomain(domain);
290290
request.setExecution(workflowExecution);
291291
request.setHistoryEventFilterType(HistoryEventFilterType.CLOSE_EVENT);
292+
request.setWaitForNewEvent(true);
292293
request.setNextPageToken(pageToken);
293294
CompletableFuture<GetWorkflowExecutionHistoryResponse> response =
294295
getWorkflowExecutionHistoryAsync(service, request);

src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java

+21-17
Original file line numberDiff line numberDiff line change
@@ -834,20 +834,8 @@ private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
834834
GetWorkflowExecutionHistoryRequest getRequest) throws TException {
835835
ThriftResponse<WorkflowService.GetWorkflowExecutionHistory_result> response = null;
836836
try {
837-
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request;
838-
if (getRequest.isWaitForNewEvent()) {
839-
request =
840-
buildThriftRequest(
841-
"GetWorkflowExecutionHistory",
842-
new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
843-
options.getRpcLongPollTimeoutMillis());
844-
} else {
845-
request =
846-
buildThriftRequest(
847-
"GetWorkflowExecutionHistory",
848-
new WorkflowService.GetWorkflowExecutionHistory_args(getRequest));
849-
}
850-
837+
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
838+
buildGetWorkflowExecutionHistoryThriftRequest(getRequest);
851839
response = doRemoteCall(request);
852840
WorkflowService.GetWorkflowExecutionHistory_result result =
853841
response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
@@ -881,6 +869,24 @@ private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
881869
}
882870
}
883871

872+
private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
873+
buildGetWorkflowExecutionHistoryThriftRequest(GetWorkflowExecutionHistoryRequest getRequest) {
874+
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request;
875+
if (getRequest.isWaitForNewEvent()) {
876+
request =
877+
buildThriftRequest(
878+
"GetWorkflowExecutionHistory",
879+
new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
880+
options.getRpcLongPollTimeoutMillis());
881+
} else {
882+
request =
883+
buildThriftRequest(
884+
"GetWorkflowExecutionHistory",
885+
new WorkflowService.GetWorkflowExecutionHistory_args(getRequest));
886+
}
887+
return request;
888+
}
889+
884890
@Override
885891
public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
886892
throws TException {
@@ -2298,9 +2304,7 @@ public void GetWorkflowExecutionHistory(
22982304
CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response = null;
22992305
try {
23002306
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
2301-
buildThriftRequest(
2302-
"GetWorkflowExecutionHistory",
2303-
new WorkflowService.GetWorkflowExecutionHistory_args(getRequest));
2307+
buildGetWorkflowExecutionHistoryThriftRequest(getRequest);
23042308
response = doRemoteCallAsync(request);
23052309

23062310
response

0 commit comments

Comments
 (0)