Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] dovecot + inotify max_user instances

101 views
Skip to first unread message

Tanstaafl

unread,
Jan 6, 2014, 2:00:02 PM1/6/14
to
Hello,

Last year Timo (the dovecot author) remoted into our server and migrated
us from courier-imap to dovecot. One of the things we ran into
afterwards was this warning in the logs:

> Warning: Inotify instance limit for user 200 (UID vmail) exceeded, disabling. Increase /proc/sys/fs/inotify/max_user_instances

He solved it by doing:

echo 1024 > /proc/sys/fs/inotify/max_user_instances

Then he said he was going to solve this permanently by changing the init
script...

Well, my shiny new server encountered the same issue once it went under
load this morning, so I had to dig out this solution - but obviously
this will come back again the next time I reboot, so I want to find a
permanent solution.

I guess I could manually modify my init script, but I'm clueless as to
where or how.

If someone can help me figure out how to do this, I'll go open a bug to
get this added to the gentoo init script permanently.

The current (gentoo) init script is:

> #!/sbin/runscript
> # Copyright 1999-2012 Gentoo Foundation
> # Distributed under the terms of the GNU General Public License, v2 or
> later
> # $Header:
> /var/cvsroot/gentoo-x86/net-mail/dovecot/files/dovecot.init-r4,v 1.1
> 2012/12/01 10:40:49 eras Exp $
>
> extra_started_commands="reload"
>
> depend() {
> need localmount
> before postfix
> after bootmisc ldap mysql ntp-client ntpd postgresql saslauthd
> slapd
> use logger net
> }
>
> checkconfig() {
> DOVECOT_INSTANCE=${SVCNAME##*.}
> if [ -n "${DOVECOT_INSTANCE}" -a "${SVCNAME}" != "dovecot" ]; then
> DOVECOT_CONF=/etc/dovecot/dovecot.${DOVECOT_INSTANCE}.conf
> else
> DOVECOT_CONF=/etc/dovecot/dovecot.conf
> fi
> if [ ! -e ${DOVECOT_CONF} ]; then
> eerror "You will need an ${DOVECOT_CONF} first"
> return 1
> fi
> if [ -x /usr/sbin/dovecot ]; then
> DOVECOT_BASEDIR=$(/usr/sbin/dovecot -c ${DOVECOT_CONF}
> -a | grep '^base_dir = ' | sed 's/^base_dir = //')
> else
> eerror "dovecot not executable"
> return 1
> fi
> DOVECOT_BASEDIR=${DOVECOT_BASEDIR:-/var/run/dovecot}
> DOVECOT_PIDFILE=${DOVECOT_BASEDIR}/master.pid
> }
>
> start() {
> checkconfig || return 1
> ebegin "Starting ${SVCNAME}"
> start-stop-daemon --start --exec /usr/sbin/dovecot \
> --pidfile "${DOVECOT_PIDFILE}" -- -c "${DOVECOT_CONF}"
> eend $?
> }
>
> stop() {
> checkconfig || return 1
> ebegin "Stopping ${SVCNAME}"
> start-stop-daemon --stop --exec /usr/sbin/dovecot \
> --pidfile "${DOVECOT_PIDFILE}"
> eend $?
> }
>
> reload() {
> checkconfig || return 1
> ebegin "Reloading ${SVCNAME} configs and restarting auth/login
> processes"
> start-stop-daemon --signal HUP --exec /usr/sbin/dovecot \
> --pidfile "${DOVECOT_PIDFILE}"
> eend $?
> }

Thx for any help...

Charles

Alan McKinnon

unread,
Jan 6, 2014, 2:40:02 PM1/6/14
to
On 06/01/2014 20:50, Tanstaafl wrote:
> Hello,
>
> Last year Timo (the dovecot author) remoted into our server and migrated
> us from courier-imap to dovecot. One of the things we ran into
> afterwards was this warning in the logs:
>
>> Warning: Inotify instance limit for user 200 (UID vmail) exceeded,
>> disabling. Increase /proc/sys/fs/inotify/max_user_instances
>
> He solved it by doing:
>
> echo 1024 > /proc/sys/fs/inotify/max_user_instances
>
> Then he said he was going to solve this permanently by changing the init
> script...
>
> Well, my shiny new server encountered the same issue once it went under
> load this morning, so I had to dig out this solution - but obviously
> this will come back again the next time I reboot, so I want to find a
> permanent solution.
>
> I guess I could manually modify my init script, but I'm clueless as to
> where or how.
>
> If someone can help me figure out how to do this, I'll go open a bug to
> get this added to the gentoo init script permanently.

[snip]

There's a more generic solution that doesn't involve hacking the init
script. Not all dovecot users will appreciate such a change be put on
their systems and that kind of config is best left up to the individual
sysadmin to determine what suits them best (no single value satisfies
everyone).

Instead, add that echo statement to a file in /etc/local.d/ and add the
local service to your default runlevel. It will tweak the
max_user_instances knob for you when it runs, same with all such local
knob fiddling you do to optimize performance.

I think overall this is better than hacking around in dovecot's start-up
script (a rather unsuitable place for it imho)



--
Alan McKinnon
alan.m...@gmail.com

cov...@ccs.covici.com

unread,
Jan 6, 2014, 3:00:01 PM1/6/14
to
I put such a thing in /etc/sysctl.conf like this -- I don't have
dovecot, but I needed it for crashplan
fs.inotify.max_user_watches=1000000
or whatever value suits.

--
Your life is like a penny. You're going to lose it. The question is:
How do
you spend it?

John Covici
cov...@ccs.covici.com

Tanstaafl

unread,
Jan 6, 2014, 4:10:03 PM1/6/14
to
On 2014-01-06 2:32 PM, Alan McKinnon <alan.m...@gmail.com> wrote:
> I think overall this is better than hacking around in dovecot's start-up
> script (a rather unsuitable place for it imho

Actually, a follow-up from Timo said he was planning on making this a
configuration setting (default blank), and the init script would then
just use this setting (if set).

Which probably makes the most sense...

Alan McKinnon

unread,
Jan 6, 2014, 4:10:03 PM1/6/14
to
On 06/01/2014 21:53, cov...@ccs.covici.com wrote:
>> Instead, add that echo statement to a file in /etc/local.d/ and add the
>> > local service to your default runlevel. It will tweak the
>> > max_user_instances knob for you when it runs, same with all such local
>> > knob fiddling you do to optimize performance.
>> >
>> > I think overall this is better than hacking around in dovecot's start-up
>> > script (a rather unsuitable place for it imho)
> I put such a thing in /etc/sysctl.conf like this -- I don't have
> dovecot, but I needed it for crashplan
> fs.inotify.max_user_watches=1000000
> or whatever value suits.


/me bangs head

Yes of course, that is a better solution for things with a sysctl.

I look at the echo statement and it writes to something in /proc
My brain said it writes to something in /sys

Now, where do I leave those memory-booster pills for old people again?

--
Alan McKinnon
alan.m...@gmail.com

Alan McKinnon

unread,
Jan 6, 2014, 5:30:01 PM1/6/14
to
Personally, I'd put it in sysctls per covics post.

Can you imagine three years hence trying to find why max_user_instances
is set non-default and *nothing* in the usual places gives a clue why?

When you eventually resort to "grep -r max_user_instances /etc" and
realise that a kernel setting is being changed in your imap server
config, you will curse and swear to the heavens (been there, done that)

Of course, it's up to you. I just like to make config settings in places
that are the most obvious to everyone who is not me


--
Alan McKinnon
alan.m...@gmail.com

William Kenworthy

unread,
Jan 6, 2014, 10:20:02 PM1/6/14
to
On 07/01/14 02:50, Tanstaafl wrote:
> Hello,
>
> Last year Timo (the dovecot author) remoted into our server and migrated
> us from courier-imap to dovecot. One of the things we ran into
> afterwards was this warning in the logs:
>
>> Warning: Inotify instance limit for user 200 (UID vmail) exceeded,
>> disabling. Increase /proc/sys/fs/inotify/max_user_instances
>
> He solved it by doing:
>
> echo 1024 > /proc/sys/fs/inotify/max_user_instances
>
> Then he said he was going to solve this permanently by changing the init
> script...

Why initscript? - as a user you should put this in a /etc/local.d
script. Leave the system files as they are.

BillK

Tanstaafl

unread,
Jan 7, 2014, 6:10:02 AM1/7/14
to
On 2014-01-06 2:53 PM, cov...@ccs.covici.com <cov...@ccs.covici.com> wrote:
> I put such a thing in /etc/sysctl.conf like this -- I don't have
> dovecot, but I needed it for crashplan
> fs.inotify.max_user_watches=1000000
> or whatever value suits.

Ok, after your and Alans comments and some more reading, I guess I
agree, but...

man sysctl, and the README in /etc/sysctl.d aren't very helpful.

Would the proper line be:

# Increase inotify.max_user_instances for dovecot
fs.inotify.max_user_instances=1024

?

And how would I have ascertained this? Ie, I wouldn't have known to use
the fs.prefix...

Thanks

J. Roeleveld

unread,
Jan 8, 2014, 12:20:01 AM1/8/14
to
Tanstaafl,

You remove '/proc/sys/' from the path. Then replace every '/' with a '.' :)

--
Joost
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
0 new messages