Description of problem: updatedb does repeated lstat() calls against all mounted filesystems, even if those filesystems are marked to be excluded in PRUNEFS. This creates a risk that updatedb will hang when it attempts to access a currently unavailable NFS filesystem (for example). Version-Release number of selected component (if applicable): mlocate-0.15-1.el5 How reproducible: Always. Steps to Reproduce: 1. Configure updatedb to exclude nfs filesystems 2. Mount an NFS filesystem on your test machine mount nfsserver:/exported_path /mountpoint 3. strace -o debug.out updatedb 4. Observe (in debug.out) that the NFS mountpoint is lstat()'ed at least once 5. Block I/O to the filesystem, e.g. with an iptables rule: /sbin/iptables -I OUTPUT 1 -d nfsserver -j DROP 6. Try to run updatedb again. Actual results: updatedb will hang if a broken NFS filesystem is mounted when it runs, even if nfs filesystems are excluded. Expected results: updatedb should skip excluded filesystems and should (therefore) be immune to their (non-)availability. Additional info: The problem appears to be in the realpath() calls that are performed in the filesystem_is_excluded() function. I am aware of BZ #235942 which has a comment saying that realpath() calls are essential but they seem to be causing a serious problem. In our environment, patching updatedb to skip the realpath() calls does not change its output.
Created attachment 153011 [details] Patch to remove realpath() calls from updatedb
Thanks for your report. The patch would break documeted behavior, and removing one of the realpath () calls would require an incompatible change (which happened anyway in rawhide mlocate-0.16). Have you tested the patch to verify it helps? From looking at the code, scan () does an lstat () on the subdirectory anyway. This lstat () can not be removed, otherwise updatedb would not skip the file systems that are mounted after updatedb starts. Because the lstat () is necessary, the hangs can't be completely avoided. The best that can be done is probably enumerating all mounts matching PRUNEFS when starting updatedb, and adding their paths to PRUNEPATHS - PRUNEPATHS are processed before the lstat (). This would help for long-term mounts (e.g. mounts in /etc/fstab), but not for short-term mounts or autofs.
I feared this would be incompatible with documented behaviour -- but it is also makes updatedb behave like the version from RHEL3 (slocate-2.7-3), which is where my client is upgrading from. The patch does fix our problem; the test I described above is how I verified it. Here is some more info on our environment, in case it helps: We have nfs and autofs in our PRUNEFS. /home is an autofs (and is always mounted). /home is not in our PRUNEPATHS. When someone logs on, their home directory is automounted (nfs). Let's say that 'rgautier' is logged on, so /home/rgautier is mounted (nfs) 1. Without the patch, updatedb (in realpath) does lstat calls on /home/rgautier 2. With the patch, it doesn't. I used strace to confirm this and can provide logs. The test I ran was (with a few names changed for clarity): % rm -f /var/lib/mlocate/mlocate.db % strace -o /tmp/unpatched.out unpatched-updatedb % rm -f /var/lib/mlocate/mlocate.db % strace -o /tmp/patched.out patched-updatedb % grep rgautier /tmp/unpatched.out lstat64("/home/rgautier", {st_mode=S_IFDIR|0755, st_size=24576, ...}) = 0 ... % grep rgautier /tmp/patched.out % In particular, the lstat() on the subdirectory that you refer to in Comment #2 above does not seem to happen in *either* case. I would appreciate detailed instructions for working around this, if it can't be fixed in the code. Alternatively, could we have an additional (command line) option to updatedb to disable the realpath() calls?
Created attachment 153211 [details] Don't call realpath() on all excluded filesystem paths if using /proc/self/mounts Thanks for the explanation, I didn't realize you were talking about mounts inside an already excluded tree. AFAICS it should be good enough to remove only the inner realpath () call to fix the nested exclusion case. This can be done safely because the paths in /proc/self/mounts are always canonical. Can you test that, please?
Tested the above patch and it does the job - thanks.
Fixed for Fedora in post-FC7 mlocate-0.17-1.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux release. Since this bugzilla is in a component that is not approved for the current release, it has been closed with resolution deferred. You may reopen this bugzilla for consideration in the next release.
I don't understand comment #7: are you saying that mlocate won't be in a future RHEL5 release? In any case, yes, please re-open this as it is directly affecting my client and we need a fix as soon as possible.
Please ignore comment #7, the bug should not have been just closed.
Is there any progress on this? Will the fix be in RHEL 5.1?
This request was evaluated by Red Hat Product Management for inclusion, but this component is not scheduled to be updated in the current Red Hat Enterprise Linux release. This request will be reviewed for a future Red Hat Enterprise Linux release.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2008-0920.html