Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how timeouts are handled in formula a logic and in libraries which call each other and how they are handled in general.

...

Summary

  • When a formula logic is executed, all timeouts are reset before each of the element element’s execution.

  • The timeout specified on any library element applies to the cumulative time spent in the library element and not the time spent in each call to the library element

    see

    . See an example below.

  • The timeouts of elements are always capped by the maximum timeout configured at the cluster level.

    • This setting default defaults to 900s (15mn).

    • It can be increased by Pricefx Support via the setting formulaEngine.script.maxTimeoutInSec.

  • The timeout of elements is set when the formula logic is pushed/saved to the partition.

    • If you increased the max maximum timeout in your cluster, don’t do not forget to resave your formula logic if needed!

  • Since Bee’s Knees 10.0, PA DataloadsData Loads, PA Distributed Calculation, DMModel Calculations and Model Calculations ignores completely ignore the timeouts in their formulalogics.

    • Be aware that this does not apply to the libraries though!

Example

...

Using a Library

In the this example below, running libs.MyLib.ElementA.getAverageMargin() for a large set of SKUs will time out after 2 seconds. The reason is that even though each time the getProductMargin method is called, it takes less than 2 seconds each time, the cumulative total time spent inside that method (because of its reference in the loop) will be more than 2 seconds.

...

Timeouts are essentially safety catches against a bad logic (such as accidental infinite loops). JVM does not have a setting like "run this thread, but only for x seconds". So we use a trick that we inject (at compile time) some code that throws an exception if the system time has elapsed the start time + timeout. Now the different logic elements are essentially Groovy script classes. So there There is no easy sharing of a script-global "start time" variable in all thinkable cases. So we resort to using a start time variable per element (normal or lib element) which is initialized at the class instantiation. So essentially It is a private script class member variable which is set to the system time in the constructor of the script class. The engine "resets" that start time for lib elements by re-instantiating the lib elements before executing every normal formula logic element. Normal elements are only instantiated once (hence the topic of "timer starts running when the element is executed first time" when you call previous elements further down).

...