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.
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.
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.