On Tue, 08 Dec 2020 14:56:11 +0100, Steinar H. Gunderson wrote:

> On Tue, Dec 08, 2020 at 02:49:48PM +0100, gregor herrmann wrote:
> > Maybe something like `ulimit -n 131072' in /etc/cron.daily/plocate
> > would be a good idea? (It seems to work for me.)
> This is a bit strange, because updatedb attempts the same thing itself,
> by means of setrlimit (and there's no reason why bash should be allowed 
> to if updatedb isn't). Do you think you could strace it and see what happens
> with the getrlimit() and setrlimit() calls?

# strace -f -v -o /tmp/plocate /usr/sbin/updatedb.plocate
/usr/share/doc/python3-webencodings: Too many open files
Hint: Try `ulimit -n 8192' or similar (current limit is 4096).


% grep -i rlimit /tmp/plocate 
23774 prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, 
rlim_max=RLIM64_INFINITY}) = 0
23774 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=4*1024, rlim_max=4*1024}) = 0
23774 prlimit64(0, RLIMIT_NOFILE, {rlim_cur=4*1024, rlim_max=4*1024}, NULL) = 0
23774 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=4*1024, rlim_max=4*1024}) = 0


It looks like changing the value to 131072 doesn't work. With

#v+
--- a/updatedb.cpp                          
+++ b/updatedb.cpp
@@ -745,6 +745,14 @@
                rlim_t wanted = std::max<rlim_t>(rlim.rlim_cur, 131072);
                rlim.rlim_cur = std::min<rlim_t>(wanted, rlim.rlim_max);
                setrlimit(RLIMIT_NOFILE, &rlim);  // Ignore errors.
+
+               if (getrlimit(RLIMIT_NOFILE, &rlim) == -1) {
+                       fprintf(stderr, "Hint: getrlimit failed.\n");
+               } else {
+                       fprintf(stderr, "Hint: getrlimit: current limit is %lu, 
max limit is %lu.\n",
+                               rlim.rlim_cur, rlim.rlim_max);
+               }
+
        }
 
        conf_prepare(argc, argv);
#v-

I get:

# /usr/sbin/updatedb.plocate
Hint: getrlimit: current limit is 4096, max limit is 4096.
/usr/share/doc/python3-webencodings: Too many open files
Hint: Try `ulimit -n 8192' or similar (current limit is 4096).


If I run the patched cronjob, i.e.
    ulimit -n 131072
    flock --nonblock /run/plocate.daily.lock $NOCACHE $IONICE nice $UPDATEDB
I see:
Hint: getrlimit: current limit is 131072, max limit is 131072.


Cheers,
gregor

-- 
 .''`.  https://info.comodo.priv.at -- Debian Developer https://www.debian.org
 : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D  85FA BB3A 6801 8649 AA06
 `. `'  Member VIBE!AT & SPI Inc. -- Supporter Free Software Foundation Europe
   `-   NP: Little Walter: Flying Saucer

Attachment: signature.asc
Description: Digital Signature

Reply via email to