teleclimber / Dropserver

An application platform for your personal web services. https://dropserver.org
Apache License 2.0
42 stars 1 forks source link

goroutine / open file leak related to sandbox #127

Closed teleclimber closed 1 month ago

teleclimber commented 1 month ago

ds-host (version: 0.13.1) crashed on my VM. It had been running for a long time. Looking at grafana: goroutines, open fds and OS threads all seemed to increase over time until something gave out as seen in log entry that preceded the crash:

sandbox/bwrapjsonstatus_linux.go:48 (BwrapJsonStatus, b.follow()) Error: too many open files

Looking at the grafana graphs in detail, the increases appear to correspond to sandbox activity. My best guess is that something isn't being closed when a sandbox is shut down.

teleclimber commented 1 month ago

Running lsof on my VM, I can see I already have a bunch of these:

ds-host  548985 549185 ds-host dropserver   59u      REG                8,0      162   262298 /home/dropserver/ds-deno-sockets/bwrap-json-status-2945489254 (deleted)
ds-host  548985 549185 ds-host dropserver   60u      REG                8,0      162   262958 /home/dropserver/ds-deno-sockets/bwrap-json-status-1967552683 (deleted)
ds-host  548985 549185 ds-host dropserver   61u      REG                8,0      162   262956 /home/dropserver/ds-deno-sockets/bwrap-json-status-1058766398 (deleted)

So that's suspect. Looking at the code I do indeed remove the "bwrap-json-status" files, but I don't close them beforehand. I guess I thought they would close automatically.

teleclimber commented 1 month ago

Reopening because there is a lot more going on here as I look more closely at output of lsof. It seems there are files getting opened repeatedly.