0
Planned

Baseline Sync calling connector entity update for all entities even when there are no value changes

Adrian Corston 4 years ago in UNIFYBroker/Plus updated by Shane Day (Chief Technology Officer) 8 months ago 3

When a Baseline Sync runs on a link the connector's update export functionality is called to update every entity, even when there are no field value changes.  This places an unnecessary load on UNIFYBroker and performs null updates against the external system for no discernible reason, and since UNIFYBroker/Plus is unable to sync any other links while this takes place can result in unnecessary processing delays while the connector is busy effectively doing nothing.

Further investigation: this only happens for some of my links in some environments and not for all of them, so I can't put together a simple example for the UNIFYBroker developers to investigate.

I have replicated this behaviour in a development environment.


This behaviour occurs when during a synchronisation PowerShell task, a value is written to the entity object, even if the value being written does not change the value.

Example:


$entity[“field”] = $someCalculatedValue


In order to prevent the behaviour from occurring, I have a workaround, whereby any assignment to an Entity will compare the value to be written before assigning it:

Function Set-EntityValue {
param(
[Parameter(Mandatory=$True)] $entity,
[Parameter(Mandatory=$True)] $FieldName,
[Parameter(Mandatory=$True)] $FieldValue
)

$oldValue = GetEntityValue -entity $entity -FieldName $FieldName
if ($oldValue -ne $FieldValue){
$entity[$FieldName] = $FieldValue
$logger.LogInformation("$FieldValue : $FieldValue -ne $oldValue")
}
}


where GetEntityValue gets the IValue.Value property, or null if the IValue does not exist.