IBM Planning Analytics Process Synchronization

Synchronization in Planning Analytics counter-intuitively does not ensure that TI processes run at the same time, in synchronization. Instead, it ensures that only one process with a given synchronized flag is allowed to run at a time. The main use cases for “synchronizing” processes in Planning Analytics by using the Synchronized function include ensuring that processes run in a defined serialized order, or to prevent certain processes from running concurrently.

Simply put, the Synchronized function allows the definition of custom flags, or semaphores, within processes. No more than one process with a given flag will be able to run at once. Any subsequent processes that have the same flag in a Synchronized function will wait to run until the first has been committed. To further explain how the Synchronized function works at a basic level, assume the following three processes exist:

  • Process to clear data in a cube
  • Process to increment data in a cube
  • Master process to run both the above, in order, using RunProcess

Without the Synchronized function being used, the following would occur:

  • The Master Process will start, run the clear data process, run the data increment process, then complete
  • The clear data process and the data increment process will likely be running at the same time.
  • Depending on which process commits last, one of the following will happen:
    • If the clear data process commits last, the cube will have no values, because it cleared the data after the data increment process committed its changes
    • If the data increment process commits last, the cube will have values, but likely be higher than expected because it did not wait for the zero out to complete before starting to increment

Neither outcome of the above is the intended outcome of running the above sets of processes. By adding the Synchronized function, it can be ensured that the processes run and complete in the correct order. In the beginning of the Prolog of both the data clear and data increment processes, a Synchronized flag is added. The Synchronized function only has one parameter; a string that is the desired flag.

With these in place, the following will happen instead:

  • The Master Process will start, run the clear data process, run the data increment process, then complete
  • The data clear process will claim the defined Synchronized flag at the start of the process, and run until completion
  • The data increment process will start and attempt to claim the Synchronized flag, but it is already being claimed by the data clear process, so it will enter a Wait state
  • Once the data clear process finishes committing, it will release the Synchronized flag, and the data increment process will be able to run, claiming the flag for itself
  • Once the data increment process finishes committing, the cube will contain the correct values

The above situation could have also been resolved by simply changing the RunProcess functions to ExecuteProcess functions to ensure processes are run in serial. Although, even with ExecuteProcess, if there are other processes that shouldn’t be running at the same time as the above, the Synchronization function would be helpful to prevent that.

Be wary to use distinct Synchronization flags with a defined purpose to avoid unintended interactions between processes. If the same flag is used for different purposes, it may lead to additional locks/waits between processes. For a more advanced use case of the Synchronized function see: https://quebit.com/askquebit/advanced-synchronized-queueing-process-groups/