AnsweredAssumed Answered

AnalysisService.QueueCalculation() Cannot backfill or recalculate analyses that are not running

Question asked by Jagan on Feb 20, 2019
Latest reply on Mar 2, 2019 by Jagan

Hello!

Before the system was upgraded to "PI Server 2018", the below sequence of AF SDK code used to work without any issues in "2016 R2 SP1". However, now after upgrading to "PI Server 2018", the same code results into "Cannot backfill or recalculate analyses that are not running"

Code

AFAnalysis analysis;

// Create analysis and set config string, TimeRulePlugIn, TimeRule.ConfigString etc..

if (analysis.Status != AFStatus.Enabled)

{

// Control comes here

analysis.SetStatus(AFStatus.Enabled);

//analysis.Status = AFStatus.Enabled; // Also this has been tried

}

// Print analysis.GetStatus and that is shows as Enabled

AFAnalysisService.CalculationMode mode = AFAnalysisService.CalculationMode.DeleteExistingData;

targetAttribute.PISystem.AnalysisService.QueueCalculation(analysis.Yield(), new AFTimeRange(dataPoint.BackFillingStartDateTime, currentUtcTime), mode);

 

From PSE, from Analyses tab, I can see the below error and this error will continue to stay that way.

For the same analysis, if I am able to back-fill by right clicking and selecting option "Backfill/Recalculate". That shows that there is no problem with analysis configuration.

The way I see this issue is, the analysis is created and then queuecalculation() is called immediately and it looks like it's taking few seconds before it's going into running state. For that reason queued calculation is going into error state. It would have been nice if Analysis service retries the queued item after the analysis is switched to running state.

 

Workaround:

I tried to make thread sleep for 5 seconds before queuecalculation() and that didn't help. Then I increased sleep time to 30 seconds then it all worked good and backfill was completed.

 

Problem:

Waiting for 30 seconds is not ok for the end users. And also, it may be that in the case that I tested it's 30 seconds and it may decrease or increase in other cases. Any suggestions on how to overcome this problem?

From AF SDK how to check if the analysis is in running state or not?

 

@Techsupport, Are you able to see why this behavior changed from "2016 R2 SP1" to "PI Server 2018" version.

Outcomes