Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query() method implementation in WorkflowStubImpl ignores RunId #602

Open
justinkov opened this issue Apr 13, 2021 · 0 comments
Open

query() method implementation in WorkflowStubImpl ignores RunId #602

justinkov opened this issue Apr 13, 2021 · 0 comments
Labels

Comments

@justinkov
Copy link

At about line 429 of com.uber.cadence.internal.sync.WorkflowStubImpl.java, the building of the QueryWorkflowParameters object doesn't set the run id if present:

QueryWorkflowParameters p = new QueryWorkflowParameters();
p.setInput(dataConverter.toData(args));
p.setQueryType(queryType);
p.setWorkflowId(execution.get().getWorkflowId());
p.setQueryRejectCondition(queryRejectCondition);

Adding something like the following fixed the problem for me:

if (execution.get().getRunId() != null) {
    p.setRunId(execution.get().getRunId());
}

Without this, the following sample code will always pull the latest run and ignore the the run id:

IWorkflowService cadenceService = new WorkflowServiceTChannel();
WorkflowClient client = WorkflowClient.newInstance(cadenceService, DOMAIN);
WorkflowStub workflow = client.newUntypedWorkflowStub(workflowId, Optional.of(runId), Optional.empty());
String result = workflow.query(queryType, String.class);

To see the problem, you would need to kick off multiple runs of a workflow that have the same workflow id. If the first run fails for some reason and the second one is successful, the sample code above will always only pull the successful run. If I add the suggested code above, I am able to successfully retrieve the failed run.

The only way then to retrieve the failed run is to use the WorkflowExecutionUtils class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants