Bug on getLastCompletionResult returns null if previous run timeout or fail

According to the doc Temporal Java SDK developer's guide | Temporal Documentation

Note that this works even if one of the cron schedule runs failed. The next schedule will still get the last successful result if it ever successfully completed at least once. For example, for a daily cron Workflow, if the first day run succeeds and the second day fails, then the third day run will still get the result from first day’s run using these APIs.

I did a simple test with a cron runs every minute to increase a counter by 1. Each run timeout if takes longer than 10s, here is the workflow method code:

@Override
    public Integer process(){
        System.out.println("\n\n=========Cron run starts.===========");
        Integer lastCompletionResult = Workflow.getLastCompletionResult(Integer.class);
        Integer currentComplitionResult = 0;
        if (lastCompletionResult == null) {
            System.out.println("No lastCompletionResult.");
        }
        else {
            System.out.println("lastCompletionResult: " + lastCompletionResult);
            currentComplitionResult = lastCompletionResult + 1;
        }
        System.out.println("currentComplitionResult: " + currentComplitionResult);
        return currentComplitionResult;
    }

I had it run for a couple minute and then set a break point to make it time out. The next run the lastCompletionResult is null. You can achieve this by turn off the worker for a few minutes then restart it as well. When you restart it never get the previous successful number. I used breakpoint to have the logs nicely in one window and here is it:

Thanks @Gordon_Sun for filling such a detailed description for the issue. This potentially looks like an issue with the server where we are not flowing through LastCompletionResult when the cron workflow times out.
Filed issue #992 to investigate this further. I’ll report back when we have a fix for this.

@Gordon_Sun,
Merged fix for this issue into master. This will be included with out next release.

Thanks for reporting the problem.

Thank you! When is your next release and does the helm chart automatically move to new release?

We will cut a new release next week and also update the helm charts.