partial success on increasing inotify limits on synology NAS

I am using a synology NAS (DS920+, DSM 7.2) and run synthing (1.23.7) from a docker container. Already a while ago I solved the inotify limit warning by running this script at boot:

sh -c '(sleep 120 && echo 204800 > /proc/sys/fs/inotify/max_user_watches)&'

More recently the warning came up again, but strangely, only for some of the folders! I manually ran the boot script again (log says successfully), but without resolving the warning. Any idea what might be going on here?

Side question: it appears I have to do this everytime I restart my docker image - why? I thought these inotify warnings are related to the machine, that’s why the boot script…

That script doesn’t “increase” the number of watches. It “sets” the number of watches. Running the script and setting the same number doesn’t accomplish anything. Just edit the script and increase the number.

Also the error only shows up on some folders because the watchers for the other folders just happened to be requested earlier and they fall under the limit. You only get the error on a folder if there are no more watchers available when that folder’s watchers are added.

Edit the script and increase the number and you should be good to go.

well I assumed it increases it from the default number of watchers…

in any case, I tried what you suggested (300000 instead of 204800), but without any success

EDIT: tried 500000 (what is a sane max number to use here?), but there is still one folder which generates the warning

How many files are you syncing? Also how much total Ram do you have in your synology?

If some directories with a lot of files don’t change often you can turn off the watcher for that folder, though you should still reset the scanning interval to something reasonable so your system isn’t constantly scanning.

I have ~200k files and my synology has 8GB RAM.

after a while those 500k watches worked…

ok thanks, will check and see what I have set in terms of watches in the different folders

A sane max number is really system specific because it’s a balance of memory usage…

Note that fs.inotify.max_user_watches is per-user – if Syncthing is running as root, any other system services that use inotify and are also running as root need to be accounted for.

Each slot in inotify’s event queue can hold up to 1KB of data, so setting fs.inotify.max_user_watches to 500000 could potentially consume up to 512MB of RAM with a full queue.

The Synology DS920+ ships with 4GB of RAM. For a typical Linux file server, it’s generally enough to minimize swapping to virtual memory. But Docker and other forms of virtualization will consume additional RAM. Since inotify is a kernel subsystem, and kernel memory pages cannot be swapped to virtual memory, available free RAM is the practical upper limit for the total maximum number of watches.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.