Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Connection Pooling Problem and Autoclosing #422

Open
sandeshjabong opened this issue Jul 15, 2016 · 2 comments
Open

Connection Pooling Problem and Autoclosing #422

sandeshjabong opened this issue Jul 15, 2016 · 2 comments
Labels

Comments

@sandeshjabong
Copy link

Hi Lunny,

I am currently a facing big problem in my connection pooling, which is as follows.

Go Version:
go version go1.6.2 Linux/amd64

MySQL Driver:
Version 1.2

XORM:
0.5.5.0711

I have set the SetMaxIdleConnection 5 and SetMaxOpenConnection 50, but still, I could see in a normal load, a number of persistent open connections are 120 with checking ESTABLISHED state as per follows.

app 8747 10568 sandeshsharma 16u IPv4 691032 0t0 TCP 127.0.0.1:57337->127.0.0.1:mysql (ESTABLISHED)

I wonder if I have set the max idle and max open then why it's reaching till 120, and I have seen if same time if I would close the MySQL connections count to remain at 120 with the following state.

app 8747 10844 sandeshsharma 38u IPv4 505058 0t0 TCP 127.0.0.1:54160->127.0.0.1:mysql (CLOSE_WAIT)

Why these connections are not getting close, because of this my application will start running out of connection or opened too many file descriptor and this causes to CRASH the service, please help soon as we need to make it live.

Thanks & Appreciated.

@lunny
Copy link
Member

lunny commented Jul 15, 2016

First of all, you can ulimit -n 65535 to set your max file descriptors on the same process or global setting.
For xorm, you have to check if you invoke Close on the below situations:
1.

sess := engine.NewSession()
defer sess.Close()
rows, err := engine.Rows()
defer rows.Close()

@debraj-manna
Copy link

debraj-manna commented Jul 17, 2016

Just to add a bit more:-

At the Mysql process list we are seeing the same number as I specified in maxIdleConnection and maxOpenConnection.

If yes then why are we seeing so much TCP connections from the app to mysql. Is it like if I specify maxOpenConnection in mysql 5 (via xorm) but my app let' say makes 100 request to mysql via xorm then will the 95 connections be waiting in TCP Connection Established state (as mysql will only allow 5)?

@lunny lunny added the question label Apr 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants