Bug 31510 - MultiInput caches too much
MultiInput caches too much
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 3.1
Other Linux
: P5 normal (vote)
: UCS 3.1-1-errata
Assigned To: Jascha Geerds
Alexander Kläser
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-24 23:01 CEST by Dirk Wiesenthal
Modified: 2013-06-13 14:37 CEST (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2013-05-24 23:01:04 CEST
Seen in Ticket #2013042621001326

When adding another row to a widget that supports multiple values the umcpCommands are cached for 100ms.

This is used especially in UDM. There are problems with complex widgets in MultiWidget. For example computers/ipmanagedclient:

DHCP service
DHCP service     IP address     MAC address

MAC address depends on MAC address (network). It is possible that the parameters used while "Searching all DHCP services)" are also used for "Getting all MAC addresses", even when MAC addresses were not set at the very moment DHCP services were queried. Thus, MAC addresses will be empty.

As soon as the user changes a MAC address, everything is fine because now the cache was invalidated (100ms).
Comment 1 Dirk Wiesenthal univentionstaff 2013-05-24 23:06:11 CEST
I suggest the following patch. After being applied I was not able to reproduce the behaviour. It should also be tested if the cache still works (and is only reevaluated when necessary).

MultiInput.js

_createHandler: function(ifunc) {
  var _valueOrDeferred = null;
  var _lastCall = 0;
+ var _lastOptions = undefined;
  return function(iname, options) {
    var currentTime = (new Date()).getTime();
    var elapsedTime = Math.abs(currentTime - _lastCall);
+   var optionsChanged = !tools.isEqual(options, _lastOptions);
    _lastCall = currentTime;
+   _lastOptions = options;

-   if (elapsedTime > 100 || !(lang.getObject('then', false, _valueOrDeferred) && lang.getObject('cancel', false, _valueOrDeferred))) {
+   if (elapsedTime > 100 || !(lang.getObject('then', false, _valueOrDeferred) && lang.getObject('cancel', false, _valueOrDeferred)) || optionsChanged) {
      _valueOrDeferred = ifunc(options);
    }
    return _valueOrDeferred;
  };
},
Comment 2 Dirk Wiesenthal univentionstaff 2013-05-24 23:26:40 CEST
Alexander, would you mind looking at the problem/solution? I guess this won't break anything. Worst case is that form loading is slower.
Comment 3 Alexander Kläser univentionstaff 2013-05-27 12:09:14 CEST
(In reply to comment #2)
> Alexander, would you mind looking at the problem/solution? I guess this won't
> break anything. Worst case is that form loading is slower.

The described problematic behaviour looks correct to me. I went through the patch and investigated it on a test system. AFAIS it looks to me as a nice workaround for the described problem. The parameter "options" contains the current list of mac addresses (i.e., the values of all its dependencies) such that a fast second call will not yield the cached value as the list of mac addresses differs (1st time empty list during initialization, 2nd time with set values).
Comment 4 Jascha Geerds univentionstaff 2013-05-28 17:08:19 CEST
The patch has been applied. I couldn't find any side effects.

- ucs3.1-1 & YAML:
univention-management-console-frontend (2.0.244-10)

- ucs3.1-2 & chanagelog:
univention-management-console-frontend (2.0.256-1)
Comment 5 Ingo Steuwer univentionstaff 2013-06-04 17:41:22 CEST
reported by another customer
Comment 6 Janis Meybohm univentionstaff 2013-06-07 12:51:47 CEST
Reported again: 2013060721001304
Comment 7 Alexander Kläser univentionstaff 2013-06-08 16:27:42 CEST
UCS 3.2
  changes → OK
  changelog → OK
UCS 3.1-1 Errata
  changes → OK
  YAML file → OK
  test → OK
Comment 8 Janek Walkenhorst univentionstaff 2013-06-13 14:37:00 CEST
http://errata.univention.de/ucs/3.1/123.html