# connectionOpener goroutine since 1500 min

**URL:** <https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897>\
**Category:** Getting Help\
**Created:** [December 13, 2023, 10:38am UTC](https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897 "2023-12-13T10:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Sharma](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/vikas_sharma/32/14456_2.png) [@Vikas\_Sharma](https://forum.golangbridge.org/u/Vikas_Sharma)\
**Post date:** [December 13, 2023, 10:38am UTC](https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897/1 "2023-12-13T10:38:16Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![skillian](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/skillian/32/7876_2.png) [@skillian](https://forum.golangbridge.org/u/skillian)\
**Post date:** [December 13, 2023, 6:16pm UTC](https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897/2 "2023-12-13T18:16:24Z")

</div>

Are you setting a max number of open connections?

---

<div class="post-metadata">

**Author:** ![michael.yue.au](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/michael.yue.au/32/15241_2.png) [@michael.yue.au](https://forum.golangbridge.org/u/michael.yue.au)\
**Post date:** [December 13, 2023, 11:53pm UTC](https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897/3 "2023-12-13T23:53:05Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [March 12, 2024, 11:53pm UTC](https://forum.golangbridge.org/t/connectionopener-goroutine-since-1500-min/33897/4 "2024-03-12T23:53:10Z")

</div>

Closed on March 12, 2024, 11:53pm UTC

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