Bug 45540

Summary: univention.admin.modules.update() is not thread safe
Product: UCS Reporter: Florian Best <best>
Component: UDM (Generic)Assignee: Florian Best <best>
Status: CLOSED FIXED QA Contact: Philipp Hahn <hahn>
Severity: normal    
Priority: P5 CC: scheinig, schwardt, troeder
Version: UCS 4.2   
Target Milestone: UCS 4.2-2-errata   
Hardware: Other   
OS: Linux   
See Also: https://forge.univention.org/bugzilla/show_bug.cgi?id=35858
https://forge.univention.org/bugzilla/show_bug.cgi?id=45284
What kind of report is it?: Development Internal 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: 2017101021000294 Bug group (optional):
Max CVSS v3 score:
Attachments: udm_init_thread_save.py
patch

Description Florian Best univentionstaff 2017-10-13 16:39:10 CEST
During the years we had a lot (bug #35858 bug #26367 bug #27685 bug #36294 bug #5970 bug #6077 bug #28223 bug #29201 bug #29094 bug #28627 bug #45284 bug #27624) of tracebacks like this:

Traceback (most recent call last):
    univention.admin.modules.init(lo, pos, ext_attr_module)
  File "%PY2.7%/univention/admin/modules.py", line 120, in init
    univention.admin.ucr_overwrite_properties(module, lo)
  File "%PY2.7%/univention/admin/__init__.py", line 60, in ucr_overwrite_properties
    ucr_prefix = ucr_property_prefix % module.module
AttributeError: 'NoneType' object has no attribute 'module'

This may be a problem if a thread calls univention.admin.modules.update() (or others) during some other thread calls univention.admin.init().
Comment 1 Florian Best univentionstaff 2017-10-13 16:50:31 CEST
Reproducer:

import univention.admin.modules
import threading
import time

def reload():
        while True:
                time.sleep(0.5)
                univention.admin.modules.update()

thread = threading.Thread(target=reload)
thread.start()

lo, po = univention.admin.uldap.getMachineConnection()
while True:
        time.sleep(0.2)
        univention.admin.modules.init(lo, po, univention.admin.modules.get('users/user'))
Comment 2 Florian Best univentionstaff 2017-10-13 18:04:57 CEST
Created attachment 9248 [details]
udm_init_thread_save.py
Comment 3 Florian Best univentionstaff 2017-10-13 18:07:23 CEST
Created attachment 9249 [details]
patch
Comment 4 Florian Best univentionstaff 2017-10-27 15:39:41 CEST
Patch slightly adapted and merged.

univention-directory-manager-modules (12.0.18-13)
9ce6c33c4ed9 | Bug #45540: Merge branch 'fbest/45540-thread-safe-modules-update' into 4.2-2
436574accaa7 | Bug #45540: fix thread safety of univention.admin.modules.update()

univention-directory-manager-modules.yaml
9ce6c33c4ed9 | Bug #45540: Merge branch 'fbest/45540-thread-safe-modules-update' into 4.2-2
227bca684ad1 | YAML Bug #45540
Comment 5 Philipp Hahn univentionstaff 2017-10-30 11:20:07 CET
OK: errata-announce -V --only univention-directory-manager-modules.yaml
FIXED: univention-directory-manager-modules.yaml → 602919ea99
OK: Jenkins
OK: Code-Review
OK: 436574accaa7
Comment 6 Arvid Requate univentionstaff 2017-11-01 13:49:25 CET
<http://errata.software-univention.de/ucs/4.2/206.html>