Querying task details... too quickly??

We are on Appian 24.1.

I have a process model with a user task followed by a write to a RecordType.  The RecordType keeps track of task performance (i.e. how long it takes users to complete the user task) for long-term trending and reporting needs.

An expression rule is called to retrieve the details once the task completes.  This rule uses queryProcessAnalytics to pull the data for the particular task in question (processId and taskId filters).  The report filters for only completed tasks

a!localVariables(
  local!rawData: a!queryProcessAnalytics(
    report: cons!XX_COMPLETED_ACTIVITY_REPORT,
    query: a!query(
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 5),
      logicalExpression: a!queryLogicalExpression(
        operator: "AND",
        filters: {
          a!queryFilter(
            field: "c8",
            operator: "=",
            value: ri!processId            
          ),
          a!queryFilter(
            field: "c7",
            operator: "=",
            value: ri!taskId            
          )
        }
      )
    )
  ),
  local!taskData: if (rule!XX_AnyArrayItems(local!rawData.data), local!rawData.data[1], {}),
  'type!{urn:com:appian:types:XX}XX_TaskMetrics'(
    processId: index(local!taskData, "c8", null),
    taskId: index(local!taskData, "c7", null),
    taskName: index(local!taskData, "c0", null),
    startTime: index(local!taskData, "c3", null),
    queueTime: index(local!taskData, "c9", null),
    workTime: index(local!taskData, "c10", null),
    completedTime: index(local!taskData, "c11", null)
  )
)

Now, this has been working just fine for over a year.  But recently, we saw an instance where Save Task Performance failed due to missing data (Task Name was null). 

NOTE:  The issue occurred on a Friday; it was noticed on Monday.  After investigating what we could (not a lot), we re-started Save Task Performance and it ran just fine.... found the task, created the record, and there was much rejoicing.

{

  speculation:  "It appears as if the part of Appian that marked the task as complete was lagging behind and Save Task Performance ran before the task completion was marked internally...  The task wasn't found by the report since it wasn't marked complete yet and thus the expression that builds the record had no data to include"

}

Is this possible?  Is there something else that might explain why queryProcessAnalytics failed to find the completed task information?

Thank you.

This is a single-server, on-premises Appian environment.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    After a user task completes, queryProcessAnalytics sometimes returns null data when queried immediately, but works fine when retried later.

    speculation:  "It appears as if the part of Appian that marked the task as complete was lagging behind and Save Task Performance ran before the task completion was marked internally...  The task wasn't found by the report since it wasn't marked complete yet and thus the expression that builds the record had no data to include"

    Yes, your speculation is correct - there's a timing gap between task completion and when the data becomes available in queryProcessAnalytics. Task completion and analytics data sync aren't instantaneous.

    I would recommend, Add a 2 second timer node between the user task and the "Save Task Performance" node to allow time for data synchronization.

    Process Analytics operates on a separate server that aggregates information.

  • 0
    Certified Lead Developer

    Yes, this is a race condition where the data from the process execution engine is synced to the process analytics engines slightly after the next node was started. As far as I know, there is no transactional guarantee that exec and analytics are in sync.

  • 0
    Certified Lead Developer

    Yes, Your speculation seems appropriate! By the time Save Task Performance ran task completion was not marked complete in report, hence the issue. 

    This can be handled in 2 ways:

    1. Adding a script task to query process report and an XOR node. Before the write records node system should check if data is available or not before Save Task Performance is executed. If its blank then process can retry the query.

    2. If you are querying in the UIT then adding a timer between the User Input Task and Save Task Performance node.