-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Strange error on killed connection #185
Comments
No, no error is transmitted. The error is actually that nothing can be recieved 😉 |
I guess the
What's your opinion? |
I'd like to hear what @gkristic thinks of this too. He's been studying it. |
I followed the code at database/sql. The The "Invalid Connection" @xaprb saw is due to the MySQL connection being no longer available when But that's not the only possibility I've seen; database/sql (Go 1.2) may have some concurrency issues that may end up with that message as well. If a (database/sql) statement is closed when a driver connection is using it, the driver statement is scheduled to be closed at the next IMHO Go's database/sql needs some careful revisiting... |
@gkristic do you suggest any changes in the driver? The database/sql package has a few flaws, I hope to make a few improvements for Go 1.3. Revisiting the dependency management is one item on my list. |
If you discover issues like this, please report it at https://code.google.com/p/go/issues/list. |
Given that these conditions (namely, connection lost or double-close by database/sql) are harmless, I'd expect the driver to skip those silently, instead of printing the "Invalid Connection" message. In my opinion, the later can either be: scary, if you don't know it's harmless; annoying, once you do; but possibly misleading, if there's an identical message printed somewhere else (and there is, except for the line number), concealing a real warning you could easily skip. If either As a side note, I'd probably add a function to tweak the logger. Currently, As soon as I have some spare time I'll prepare a small example for the issue I mentioned before and write a report. Thanks! |
@arnehormann Oh, man... exactly that. I've been working with v1.1. I checked the other stuff at master too before posting, but forgot to check logging. Sorry and thanks! |
@gkristic not a problem at all 😀 |
Any changes which should be done before the next release? PRs welcome :) |
Hey guys, new user of go-sql-driver here. I'm noticing similar issues, but was wondering if someone could help me confirm the cause is the same? In long running crons that utilize goroutines I'm routinely receiving the following.
I'm more than willing to get my hands dirty here, just looking for some guidance on how to approach the problem. Is this "Invalid Connection" error safe to ignore in certain circumstances? Is there a way to automatically grab another connection if this is detected? |
Uh, oh... now that I see, I missed the comment by @julienschmidt from last Friday. (I apologize Julien.) @rmulley, it looks like you've hit the same problem I was describing above. Look at this comment. The "Invalid Connection" at statement.go:24 is harmless. The driver should do the appropriate thing by choosing a different connection. I'm not sure about the "Busy buffer" though; I don't recall having seen that. It's been quite a while since I checked this code. I'll set some time apart to have a look at it again and see whether I can help. Unfortunately, that can't happen before the end of next week. But I'll get back to you by then. |
@rmulley: To me this seems unrelated to this issue. It seems like |
According to #206 this error actually goes away when go is run from tip. Is that not actually the case? |
First off, sorry for the late response I was on vacation and then forgot to follow up. I ensured I have the newest version of the MySQL Driver and am now testing with Go 1.3. It does look like I am seeing more detail in the error message now.
Is this a MySQL issue on my end? (I haven't found anything useful online on how to resolve this issue) |
i've encountered the same problem as rmulley described. what was different is that the "busy buffer" appeared in extremely short query (as short as 1 Query + 2 Exec's). i feel the problem is related to prepared statements. i found that if i have prepared a statement in a transaction, like
i must close this stmt before i prepare another statement, or i will encounter "busy buffer" each time. if i don't use prepared statements, for example doing directly to tx like
or
, it was fine. and, if i prepare a statement and then executing other Query or Exec other stuffs, it is fine too... just don't prepare another statement without closing the previous one, and it looks fine. hope it is really where the problem is. thanks. |
Can you maybe create a small Go program with which the error can be reproduced? |
I think this is the problem: package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, _ := sql.Open("mysql", "/")
defer db.Close()
tx, err := db.Begin()
if err != nil {
panic(err)
}
defer tx.Commit()
stmt1, err := tx.Prepare("SELECT 1")
if err != nil {
panic(err)
}
rows1, err := stmt1.Query()
if err != nil {
panic(err)
}
stmt2, err := tx.Prepare("SELECT 2")
if err != nil {
// rows1 is not closed -> triggers busy buffer because transaction is on one connection
// and stmt1, stmt2 use the same one.
// Move rows1.Close() in front of tx.Prepare and it disappears
panic(err)
}
rows2, err := stmt2.Query()
if err != nil {
panic(err)
}
rows1.Close()
rows2.Close()
stmt1.Close()
stmt2.Close()
} |
I just ran into a similar busy buffer issue and can confirm that @arnehormann seems to be correct. The issue happens when attempting to use the same transaction for multiple queries while a rows object is still open |
Hi guys, I don't know if this was resolved in any way. I'm seeing this issue in short inserts performed with "Exec" -> var sql = "insert into table (f1,f2 ... f25) values (?,?, ... ?)" After about 4000, sometimes 5000 inserts I get "Unexpected EOF" and "Busy Buffer". Thanks, |
@sal - what happens when you use go 1.4? On Wed, Dec 31, 2014 at 10:11 PM, Sal A. Magnone notifications@github.com
|
Thanks for your reply. 1.4 – same error. Died at 4205 inserts in about 50 minutes (there is net and screen i/o between each insert). I’ve refactored the code to optionally pick up where it left off the previous time. So not critical for this app, but will be could be critical for other apps in this project if this a cumulative request problem. -Sal From: carbocation [mailto:notifications@github.com] @sal - what happens when you use go 1.4? On Wed, Dec 31, 2014 at 10:11 PM, Sal A. Magnone <notifications@github.com mailto:notifications@github.com >
— |
Is this thread turning into a few threads now? Should the most recent comments be put into a new issue and this one closed? |
@xaprb I agree, I think there are a few threads going on now. We can probably close this one and take from #185 (comment) into a new issue. |
When I kill connections that have long-running queries, I get things like this:
I'm used to seeing this error:
As far as I know, that error is actually sent across the network connection back to the client that got killed. Is this being masked in the driver or the database/sql, or is it not an error transmitted via the protocol as I think? Can we make it more clear what's happening, somehow?
The text was updated successfully, but these errors were encountered: