Too many open files on NetBSD - where to start?

Kia ora koutou, I’m running syncthing v1.27.6 “Gold Grasshopper” (go1.22.2 netbsd-amd64) and I can see that it seems to be holding open all the files in my (so far only one) shared folder open. The syncthing process has 2654 files open when trying to share a folder heirarchy with 2361 files in it.

The Linux version I’m running on Arch Linux (syncthing v1.27.6 “Gold Grasshopper” (go1.22.2 linux-amd64) syncthing@archlinux) has 56 files open when sharing a folder heirarchy with 3629 files.

Using ktrace I can see a whole lot of files getting opened, but I never see them get closed.

I’ve doena bit of Go programming over the years, but this program is a bit bigger than I’m used to. If someone could point me towards somewhere to look, I’d appreciate it.

Ngā mihi, Lloyd

You don’t say which files are open, but on the assumption that it’s the files being served: we open the file, read one block, then close it again: syncthing/lib/model/model.go at 79ae24df7688c37a7a897218c87bff412a887b9d · syncthing/syncthing · GitHub

This doesn’t differ between platforms…

It is the files being served. I can see that in the ktrace output.

Hmm. I don’t recall seeing the files getting read either, so that’s where I’ll look first.

I’m not really expecting much code other than the obvious inotify/kqueue stuff to differ between Linux and NetBSD. I’m open to possibility that the problem could exist anywhere, not just core syncthing code.

Ngā mihi, Lloyd

Aaaand it’s kqueue. The BSD kqueue system requires the files being monitored to be held open. Oh well. Time to increase that system’s file limits I guess.

Ngā mihi, Lloyd

1 Like