Bug 42475 - sysvol sync: lock is not released if process is killed
sysvol sync: lock is not released if process is killed
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Samba4
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.1-3-errata
Assigned To: Felix Botner
Arvid Requate
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-22 14:00 CEST by Felix Botner
Modified: 2016-10-20 12:40 CEST (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.171
Enterprise Customer affected?:
School Customer affected?: Yes
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 Felix Botner univentionstaff 2016-09-22 14:00:22 CEST
Stop cron
/etc/init.d/cron stop

Added "sleep 1000" to /usr/share/univention-samba4/scripts/sysvol-sync.sh after "flock -n 9 || exit 0" line.

Start script
bash -x /usr/share/univention-samba4/scripts/sysvol-sync.sh

Kill both sysvol-sync.sh processes
kill 563 565

Restart script

-> bash -x /usr/share/univention-samba4/scripts/sysvol-sync.sh
+ . /usr/share/univention-lib/ucr.sh
++ /usr/sbin/univention-config-registry shell hostname samba4/sysvol/sync/host
+ eval hostname=master
++ hostname=master
+ DEBUG=false
+ SYSVOL_PATH=/var/lib/samba/sysvol
+ SYSVOL_SYNCDIR=/var/cache/univention-samba4/sysvol-sync
+ SYSVOL_SYNC_TRIGGERDIR=/var/cache/univention-samba4/sysvol-sync/.trigger
+ PROCESS_LOCKFILE=/var/lock/sysvol-sync-process
+ SYSVOL_LOCKFILE=/var/lock/sysvol-sync-dir
+ LC_ALL=C
+ flock -n 9
+ exit 0

Now flock can't get the lock and immediately exists


Problem seems to be the missing flock -u

       -u, --unlock
              Drop  a  lock.  This is usually not required, since a lock is automatically dropped when the file is closed.  However, it may be required in
              special cases, for example if the enclosed command group may have forked a background process which should not be holding the lock.

Replacing "flock -n 9 || exit 0" with "flock -un 9 || exit 0" works for me
Comment 1 Felix Botner univentionstaff 2016-09-22 14:19:30 CEST
fixed in univention-samba4 (72750) in errata4.1-3, merged to 4.2-0

univention-samba4.yaml
Comment 3 Felix Botner univentionstaff 2016-09-23 14:26:12 CEST
(In reply to Stefan Gohmann from comment #2)
> Please check the YAML file:
> http://jenkins.knut.univention.de:8080/job/UCS-4.1/job/UCS-4.1-3/job/
> ErrataValidation/lastCompletedBuild/testReport/

fixed (univention-samba in yaml instead of univention-samba4)

Also had to fix debian/rules (split override_dh_fixperms into override_dh_fixperms and override_dh_fixperms-indep), as we no longer build the all packages on amd64.
Comment 4 Arvid Requate univentionstaff 2016-10-17 16:51:48 CEST
Ok, works and the advisory is ok.
Comment 5 Janek Walkenhorst univentionstaff 2016-10-20 12:40:40 CEST
<http://errata.software-univention.de/ucs/4.1/309.html>