Every Process Instance has a Version Filter. The Version Filter defines the strategy for selecting the versions of Business Objects used during the execution of a Process Instance. The most common type of Version Filter in production is the Timestamp Filter. This type of Version Filter contains a timestamp which is used to find the latest committed version of a Business Object at or before the date and time specified by that timestamp.
Before Appway 10.1.0, a new Process Instance was always created with a Timestamp Filter using the current date and time as a timestamp.
Example: When starting a Process on August 3, 2020 at 11:30 AM, the Process Instance used a Timestamp Filter with a timestamp pointing at this same date and time.
This way, a Process Instance was executed with the versions of Business Objects being "active" (committed) at the point in time when the Process Instance was started. Changes to Business Objects or Packages after the Process Instance was started had no effect on that Process Instance.
One side-effect of this strategy was that every Process Instance had a Timestamp Filter with a different timestamp. 100 new Process Instances typically used 100 different Timestamp Filters, assuming that Process Instances were not started at the exact same time. This made it very hard for Appway to cache certain information "per Version Filter", since the number of entries in such a cache grew with the number of different Version Filters and, therefore, with the number of active Process Instances.
Starting with Appway 10.1.0, the rule for assigning a Version Filter to a Process Instance has changed. New Process Instances still get a Timestamp Filter with a timestamp, but this timestamp is no longer the current date and time but, instead, the date and time of the latest commit operation on Business Objects or Packages on that Appway system. We say that this Version Filter is "aligned" with a commit timestamp.
Example: When starting a Process on a system where the last commit operation was performed on July 5, 2020 at 3:15 PM, the Process Instance uses a Timestamp Filter with a timestamp pointing at this commit date and time, independent of the current date and time.
The reasoning behind is that there are usually much fewer commit operations (in the range of 1 to 30 per month) on a system compared to new Process Instances (in the range of 30 to 1.5 million per month). In an ideal case with short-living Process Instances, all active Process Instances may use the same 1 to 10 Version Filters. This allows Appway to implement more effective caching strategies, especially for information aggregated across multiple Business Objects.
A good example is a cache to remember all properties of a Data Class, including all properties inherited from all parent Data Classes. These properties must be collected by traversing the inheritance hierarchy of a Data Class. Since different Data Classes can have different version histories, the list of properties can be different after every commit. By caching properties "per Version Filter" and using Timestamp Filters configured to use commit timestamps, such a cache can hold the maximum amount of information with a minimum number of cache entries.
First of all, this change only affects newly started Process Instances. Existing Process Instances started before upgrading to Appway 10.1.0 are not affected in any way.
Second, there is no impact on how Appway executes Process Instances, e.g. on the versions of Business Objects Appway selects during runtime.
However, consider the following case:
- If a Solution uses custom Java or Appway script code to read the Version Filter of a Process Instance,
- And a Timestamp Filter uses its timestamp for other operations,
- And this timestamp corresponds to the start date and time of the Process Instance,
Then, this Solution needs to be updated to use the "creationTime" property of the Process Instance instead.
Important! This optimization step is optional. Please, read this article carefully and evaluate the benefits for your Solution before taking any action, as this migration could take a long time depending on the number of Process Instances in your Solution. Cache statistics may give you an indication whether your system could perform better after such migration.
As mentioned above, if a system is upgrade to Appway 10.1.0 or greater, existing Process Instances are not modified in any way. Every Process Instance keeps using its initially assigned Version Filter until it completes. If a system contains mainly short-living Process Instances, such old Process Instances will complete and disappear very quickly, and all newly started Process Instances will use Version Filters aligned with commit timestamps.
However, although the existing Process Instances continue to live for a longer time, we do not expect them to have a negative impact on the system. All caches implemented in Appway have reasonable control mechanisms to limit the maximum size of the cache. The caches may not work at their maximum efficiency, but the overall performance will still be better than without these caches before Appway 10.1.0
To unlock the full potential of these caches, Appway provides a migration tool in the form of a script language function as part of Functions Extension (a mandatory extension for all Appway installations):
Migration:AlignTimestampFilters(Boolean $simulate) : String
This function is intended to be invoked from the Interactive Script Editor. It scans all Process Instances owned by the local cluster node and align their Timestamp Filters with commit timestamps.
The migration function returns a report with some statistics:
Cluster Node: node-1
Process Instances: total=5560, ignored=0, skipped=0, errors=0, updated=5560
Unique Timestamps: before=5560, after=15
See the following information on each type of statistic:
- total — Total number of local Process Instances (owned by that cluster node).
- ignored — Number of Process Instances ignored because they do not need to be migrated. They either have been deleted in the meantime, use a different Version Filter (e.g., HeadFilter), are already aligned with a commit timestamp, and so on.
- skipped — Number of Process Instances which should have been migrated but have been skipped due to some issue. They are either suspended, paused, have been modified after the migration has started, use a timestamp which is older than the oldest commit, are already locked by another thread, and so on.
- errors — Number of Process Instances where the migration has caused an exception. Details can be found in the log files.
- updated — Number of migrated Process Instances.
Note that the number of unique timestamps before and after the migration is only calculated on the Process Instances which have actually been migrated, not on all Process Instances.
The migration function supports a simulation mode, which is enabled by default. In simulation mode, the function does not make any changes to Process Instances, but still tries to estimate the number of Process Instances which would be modified:
Cluster Node: node-1
Process Instances: total=4893, ignored=3, skipped=0, errors=0, updated=4890 (simulated)
Unique Timestamps: before=4893, after=3
Simulation mode is enabled or disable by passing true (enabled, default) or false (disabled) as first parameter:
// with simluation mode enabled:
Migration:AlignTimestampFilters()
Migration:AlignTimestampFilters(true)
// with simulation mode disabled:
Migration:AlignTimestampFilters(false)
Since the function may potentially modify a lot of Process Instances, and in order to avoid an overload of the Cluster Storage backend due to many write operations, the function throttles its work not to exceed 100 modified Process Instances per second. As a result, executing the function on a cluster node with 60'000 active Process Instances can take up to 10 minutes. Throttling is disabled in simulation mode, but the number of Process Instances reported as 'updated' in simulation mode can be used to estimate the execution time when simulation mode would be disabled.
To execute the function on every cluster node in parallel, the function call can be distributed to all cluster nodes using the helper function ExecuteDistributed:
`ExecuteDistributed(Migration:AlignTimestampFilters(false))`
The output then contains reports from all cluster nodes:
Cluster Node: node-1
Process Instances: total=5560, ignored=0, skipped=0, errors=0, updated=5560
Unique Timestamps: before=5560, after=12
Cluster Node: node-2
Process Instances: total=5440, ignored=0, skipped=0, errors=0, updated=5440
Unique Timestamps: before=5440, after=8
Due to the fact that Process Instances should be more or less evenly distributed across cluster nodes, and the fact the the function is executed in parallel on all cluster nodes, the total execution time should be in the same range as when executing the function on only one cluster node.