-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keepalives support #999
base: master
Are you sure you want to change the base?
Keepalives support #999
Conversation
9b159b5
to
6ecc178
Compare
Go 1.13 tests fail because I used
|
I am running the go process in a debian 8 OS. The connections does not get auto cleaned for me until i restart the go process. I am assuming it was because of bad connections not getting terminated. By default 15 seconds do you mean Keep-alives in linux system with lib/pq are already working? And this PR makes it configurable? |
They should be working golang/go#23459. You can check the number of probes with |
Its 9 for me, let me check why the connections are not getting cleaned.
|
Confirmed mine was a connection leak, db.Stats() helped a great deal ! |
sql.Open will use driver's OpenConnector instead of its Open method. This will enable TCP keepalive support. Note, testDriver was added for TestRuntimeParameters since it expects old fashioned Driver interface (without OpenConnector).
I haven't tried these changes on prod, but at least
|
Got rid of OpenConnector for simplicity's sake. Noticed "pq: current transaction is aborted" in go18_test.go:212, but it doesn't seem to be related. The same issue popped up in lib#921.
Proposing to add
keepalives
andkeepalives_interval
parameters support #360.By default
KeepAlive
is set to 15 seconds https://godoc.org/net#Dialer.From what I understand, on Linux that would set
TCP_KEEPIDLE=15
(idle time) the time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes.TCP_KEEPINTVL=15
(retry interval) the time (in seconds) between individual keepalive probes.If
TCP_KEEPCNT=8
(the maximum number of keepalive probes TCP should send before dropping the connection), thenthe total timeout would be
TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT = 15 seconds + 15 seconds * 8 pings = 135 seconds
.