Skip to main content

Too many open files

info

If you need expert help to resolve this or any other issue, please review our technical support terms and conditions.

Description

With a large number of cameras, around 128, you may run into Inotify limits — when adding a camera, you may then see the following message in the server log:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xe8 pc=0xdda663]

goroutine 1258 [running]:
gitlab.com/yuccastream/yucca/pkg/runner/latest.(*Runner).GetStats(...)
/builds/yuccastream/yucca/pkg/runner/latest/runner.go:327
gitlab.com/yuccastream/yucca/pkg/server/executor/exec.(*Worker).GetStream(0xc002b74500)
/builds/yuccastream/yucca/pkg/server/executor/exec/worker.go:188 +0xa3
gitlab.com/yuccastream/yucca/pkg/server/executor/exec.(*Executor).StatusStream(0xc0003f01c0, 0xc00074b6c0)
/builds/yuccastream/yucca/pkg/server/executor/exec/executor.go:126 +0xb8
gitlab.com/yuccastream/yucca/pkg/server.(*Server).stateWatcher(0xc000c1e000)
/builds/yuccastream/yucca/pkg/server/server.go:914 +0x233
created by gitlab.com/yuccastream/yucca/pkg/server.(*Server).Start in goroutine 1
/builds/yuccastream/yucca/pkg/server/server.go:695 +0x4db

And in the log of one of the cameras:

Error: too many open files

By default, many Linux distributions have the following parameters set:

grep NOFILE /etc/systemd/system.conf
#DefaultLimitNOFILE=1024:524288

Solution

To increase the limits, run:

sed -i 's/^#DefaultLimitNOFILE=.*/DefaultLimitNOFILE=10240:524288/' /etc/systemd/system.conf

Also increase this parameter for the yucca.service systemd unit, in the /lib/systemd/system/yucca.service file:

mkdir -p /etc/systemd/system/yucca.service.d/
cat > /etc/systemd/system/yucca.service.d/override.conf << 'EOF'
[Service]
LimitNOFILE=10240
EOF

sudo systemctl daemon-reload
sudo systemctl cat yucca # проверить

Then apply the settings and restart the yucca.service process:

sudo systemctl restart yucca.service