connectionOpener goroutine since 1500 min

Hi Everyone,

We are chasing a memory allocation/leak problem at our production setup. Added PProf and found that a sql goroutine is awak since the build started.

Curious to know if this is critical when goroutine takes more than 1500-1800 minutes ?

Here is the code snippet

Directory Structure

MAIN file.GO

Db.GO

Pprof : pprof shows a goroutine connection opener whose time keeps increasing .
goroutine 19 [select, 1482 minutes]:
database/sql.(*DB).connectionOpener(0xc00049d110, {0xf83e10, 0xc000181a40}) /usr/local/go/src/database/sql/sql.go:1218 +0x8d
created by database/sql.OpenDB /usr/local/go/src/database/sql/sql.go:791 +0x18d

goroutine 26 [select, 1482 minutes]: database/sql.(*DB).connectionOpener(0xc00049c1a0, {0xf83e10, 0xc00011c0f0}) /usr/local/go/src/database/sql/sql.go:1218 +0x8d
created by database/sql.OpenDB /usr/local/go/src/database/sql/sql.go:791 +0x18d

is it normal to have this open for such a long time ?
from https://kumakichi.github.io/goroutine-leak.html seen that we need to close 
 the  connection.but closing the connection 
 using the reference of db is correct ? I mean suspecting the overall structure.
 Kindly help

Are you setting a max number of open connections?

Your DB connection should not be in a goroutine.
if you need a DB connection you should set it at your application starting stage, I mean put it into your main()

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.