We've recently gotten an app written in golang that stores information about visits in a database.
We are facing the following error in this legacy code that is already in production:
http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 1s
We believe that this errors are caused by calls to the database that are getting opened, but can't find the point where this calls get stacked.
Is there a way to check if there are database calls opened and where in the code are?
We've seen that the code uses the github.com/astaxie/beego/orm
library
and the calls are made using o := orm.NewOrm()
but we don't know where else to look for.
UPDATE
The too many open files error appears when the total amount of open files for that process (lsof -u myuser | grep "10930" | wc -l
) reaches 2048
Also, the output of lsof -u myuser | grep "protocol: TCPv6"
throws something like this:
ana 10930 myuser 3405u sock 0,8 0t0 307230406 protocol: TCPv6
ana 10930 myuser 3407u sock 0,8 0t0 307230465 protocol: TCPv6
ana 10930 myuser 3408u sock 0,8 0t0 307231438 protocol: TCPv6
ana 10930 myuser 3427u sock 0,8 0t0 307234900 protocol: TCPv6
ana 10930 myuser 3441u sock 0,8 0t0 307236431 protocol: TCPv6
ana 10930 myuser 3446u sock 0,8 0t0 307237446 protocol: TCPv6
ana 10930 myuser 3457u sock 0,8 0t0 307239557 protocol: TCPv6
And the number of this sock connections is getting higher and higher.
Does someone know what these connections are and why are they getting opened?