Bug ID 1222946
Summary raise default inotify instance limit
Classification openSUSE
Product openSUSE Distribution
Version Leap 15.5
Hardware x86-64
OS openSUSE Leap 15.5
Status NEW
Severity Normal
Priority P5 - None
Component Kernel
Assignee kernel-bugs@opensuse.org
Reporter obs@akr.yagii.de
QA Contact qa-bugs@suse.de
Target Milestone ---
Found By ---
Blocker ---

especially when running Unison, I quite often experienced the following error:

`Fatal error: exception Unix.Unix_error(Unix.EBADF, "set_nonblock", "")`

Running "strace unison-fsmonitor" yielded:
```
fcntl(0, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(0, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
fcntl(1, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(1, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
inotify_init()                          = -1 EMFILE (Too many open files)
fcntl(-1, F_GETFL)                      = -1 EBADF (Bad file descriptor)
write(2, "Fatal error: exception Unix.Unix"..., 71Fatal error: exception
Unix.Unix_error(Unix.EBADF, "set_nonblock", "")) = 71
exit_group(2)                           = ?
+++ exited with 2 +++
```

Sometimes closing open IDEs or Firefox has helped, but the culprit seems to be
the standard value of

fs.inotify.max_user_instances = 128

After doubling the number, I was able to use Unison, again. 

Others have observed this issue, too:

https://intellij-support.jetbrains.com/hc/en-us/articles/15268110231826-Inotify-Instances-Limit-Linux
---quote
For an intelligent IDE, it is essential to be in the know about any external
changes in files it working with - e.g. changes made by VCS, or build tools, or
code generators, etc. For that reason, the IntelliJ platform spins a background
process to monitor such changes. The method it uses is platform-specific, and
on Linux, it is the Inotify facility.

Before operating, inotify requires an "instance" to be initialized. While the
default per-user limit of instances used to be high enough, a growing number of
programs that also use inotify may lead to instance shortage - in which case
file watcher will be unable to start.

If this is the case, the limit may be temporarily increased by the following
command:

sudo sh -c "echo 256 > /proc/sys/fs/inotify/max_user_instances"

Don't forget to restart the IDE afterward.
---quote

My workaround at present is:

`sysctl -w fs.inotify.max_user_instances=256 >> /etc/sysctl.d/unison.conf`

This is also documented at https://github.com/bcpierce00/unison/issues/1019


You are receiving this mail because: