Skip to content
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

Infinite connection creation loop after session termination #33

Closed
biinilya opened this issue Aug 22, 2013 · 7 comments
Closed

Infinite connection creation loop after session termination #33

biinilya opened this issue Aug 22, 2013 · 7 comments

Comments

@biinilya
Copy link

netstat -tn | grep 9042 | wc -l && go run gocql_demo.go && netstat -tn | grep 9042 | wc -l
0
2013/08/22 13:44:49 failed to connect to "127.0.0.1:9042": dial tcp 127.0.0.1:9042: cannot assign requested address
2013/08/22 13:44:49 failed to connect to "127.0.0.1:9042": dial tcp 127.0.0.1:9042: cannot assign requested address
28231

Sample demo app to reproduce

package main

import (
"time"
"tux21b.org/v1/gocql"
)

func main() {
conn := gocql.NewCluster("build-12-04")
sess := conn.CreateSession()
sess.Close()

time.Sleep(60 * time.Second)

}

@phillipCouto
Copy link
Contributor

Issue #30 could be related to this as once the session closed and fell out of scope the library continued to create new connections.

Nice find!

@tux21b
Copy link
Contributor

tux21b commented Aug 22, 2013

Ouch, many thanks for pointing that out. That would also explain Phillip's "cannot assign requested address" error because all ports are already exhausted. I will look into it.

@phillipCouto
Copy link
Contributor

I figured out where the problem is with this. I will write a commit later on today to resolve this issue.

@tux21b
Copy link
Contributor

tux21b commented Sep 6, 2013

Please wait with this change. The current implementation is quite hard to follow, because the connection state (connect, delay, reconnect, change keyspace, add to pool) is representation by different goroutines. I have a local implementation of a Host type that manages the connection pool to a single node and doesn't suffer this problem. I will commit it on the weekend.

@phillipCouto
Copy link
Contributor

Ok to solve the issue I just changed cluster.go Line 182 to:

if !c.close {
    go c.connect(conn.Address()) // reconnect
}

This way when the connections throw errors from being forcefully closed the cluster doesn't keep trying to recreate them.

I will hold off on the commit but you can work this in if you feel it is still valid with your upcoming changes.

@tux21b
Copy link
Contributor

tux21b commented Sep 6, 2013

Ah, ok. If it's really that simple feel free to commit it (I gave you contributor access to the repo here), but please, do not waste too much time with this at the moment, because the connection pool logic is likely to change anyway.

@phillipCouto
Copy link
Contributor

This issue has been resolved with commit c0c4daf

martin-sucha pushed a commit that referenced this issue Jan 22, 2021
added training section with links to Scylla University
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants