NumericAggregation within a work item triggers an infinite loop


In case you set up a numeric aggregation within the same work item, this might result in an infinite loop. Normally a change of a source value should only trigger a single update of the target field thanks to the explicit check in the code to only update the target field in case the aggregated value is different than the current stored value.
However in case doubles are used you have a possible rounding issue to take into account. The code does not check on the small difference that can occur due to the internal represenation of doubles in .Net.
This results in the work item ending up in an infinite update loop and causes a lot of records in the table 'WorkItemsWere' to be created (history).
You are able to notice this after a while as opening and saving the work item will take up drastically more time due to this.

To resolve this issue you could for example modify line 52 in Aggregator.cs in the following way:

if (Math.Abs(aggregateValue - targetWorkItem.GetField(configAggregatorItem.TargetItem.Name, 0)) < 0.1)
Closed Feb 14, 2015 at 3:17 PM by giuliov
Moved to GitHub Issue #8


Tumbleweed wrote Jan 4, 2013 at 9:00 AM

Got the same issue. Aggregator calculated the value 2.9999999 and thus triggered an infinite loop. My mail-inbox exploded and i had like 2000 mail before i figured out what happened.
Will try you modification.


wrote Feb 14, 2013 at 7:34 PM

wrote May 15, 2013 at 2:40 AM

wrote Feb 14, 2015 at 3:17 PM