-
Notifications
You must be signed in to change notification settings - Fork 622
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
close connections properly #139
Conversation
@@ -248,8 +251,7 @@ func (c *Conn) execSimple(op operation) (interface{}, error) { | |||
f, err := op.encodeFrame(c.version, nil) | |||
f.setLength(len(f) - headerSize) | |||
if _, err := c.conn.Write([]byte(f)); err != nil { | |||
c.conn.Close() | |||
c.cluster.HandleError(c, err, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is HandleError()
no longer called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember it correctly execSimple() is only called from
startup()->Connect() and therefore needs not call HandleError
On Mon, Mar 31, 2014 at 9:14 AM, Ben Hood notifications@github.com wrote:
In conn.go:
@@ -248,8 +251,7 @@ func (c *Conn) execSimple(op operation) (interface{}, error) {
f, err := op.encodeFrame(c.version, nil)
f.setLength(len(f) - headerSize)
if _, err := c.conn.Write([]byte(f)); err != nil {
c.conn.Close()
c.cluster.HandleError(c, err, true)
Why is HandleError() no longer called?
Reply to this email directly or view it on GitHubhttps://github.com//pull/139/files#r11100738
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ive been thinking about this and think this is correct action as it could lead to an infinite loop of connect -> startup -> execSimple -> handleError -> connect
Should isClosed be made thread safe? |
Probably. but what is the worst that can happen :) On Mon, Mar 31, 2014 at 9:49 AM, Chris Bannister
|
Personally, I prefer if the Conn is kept in a resource pool and only put Also as I mentioned earlier, in spite of the fixes in the #139 the number Here is something I wrote for my company and it solved all the problem On Mon, Mar 31, 2014 at 10:22 AM, Harpreet Sawhney <
|
Based on the Travis output, looks like some changes didn't quite make it into the PR?
|
(first and foremost, I should say thank you for putting code forth for tackling this, this problem has been on my own long list of things to get to for a very long time and I'm ELATED to see movement on it 😁 😁 😁 😁 ) |
Have fixed the build error. Please note the New Session code is incomplete but can be merged into the On Tue, Apr 1, 2014 at 7:27 AM, Mikhail P notifications@github.com wrote:
|
My only concern with this is the session is managing connections. This the case with the current code and causing these issues of spaghetti code for closing connections and handling errors. I know this may solve an issue now but I think we need to move away from the session or cluster managing connections and leave that to a connection pool implementation. This way connection management is in 1 spot. |
Another thing the new session implementation code in the PR I feel is outside the scope of this particular PR. Having code that isn't complete in the master isn't a great thing either that's why we make forks and branches to submit complete units of code that work, have comments, and test cases. |
Agreed on both counts. I actually intended only to push out the connection close fixes. But being The current session code is only cause we use in this production and needed On Tue, Apr 1, 2014 at 9:46 AM, Phillip Couto notifications@github.comwrote:
|
If you could rebase this to remove the session changes and submit hem separately that would be great. |
@Zariel This is now done. |
Gonna try and run this in our lab environment to see if it eradicates the |
🤘 I had identified a query that produced that error every 5 or so requests. I can no longer get it to happen at all with this patch. Unfortunately don't have time to do anything more scientific at the moment, but it is definitely a night and day difference (as soon as I reverted to the pre-patched version, it dutifully 500'd on the first reload 😆 ) Thank you so much @harpreet-sawhney |
That is great news. Would you be able to share a query we can test with? |
May have been premature, gonna have to do the scientific thing after all. Due to a quirk in our build process, what the code I thought was running the new version was not actually, and I had just gotten lucky 😳 I don't think it's so much a particular query as query concurrency. I'll try to hook up apachebench or something similar later on. |
Retract tags taken by mistake from kiwicom/gocql
Creates an additional flag isClosed to mark that the connection has been closed.
The Pick method is modified to ensure that a closed or at capacity connection is not picked