-
Notifications
You must be signed in to change notification settings - Fork 16
ExternalLobVar not thread safe #26
Comments
Just to add more info: according to Go documentation, stmt is supposed to be safe to be used across multiple goroutines, but I've decided to put it inside the goroutine just to eliminate that uncertainty:
And it exhibits the same issue. |
It seems that this is not really with ExternalLobVar but with stmt. BUT there is something fishy somewhere: see TestGetLobConcurrent: that prepares a different statement for each goroutine, but suffers from the same error! |
I constructed the original test cases according to the go documentation for DB.Prepare
I hope I'm not mis-interpreting the documentation though. Also, in my 2nd comment, I also tried creating a new stmt for each goroutine, and it still fails with the same error. |
Hi, Check out the documentation of driver Prepare: http://golang.org/pkg/database/sql/driver/#Conn and golang.org/pkg/database/sql/driver/#Stmt: "Stmt is a prepared statement. It is bound to a Conn and not used by multiple goroutines concurrently. " So database/sql does the magic here, and I need to check out what. |
Prove that Cursor is closable while the LOB is opened and used.
As database/sql closes the connection under the lob, use SetMaxOpenConns and SetMaxIdleConns to avoid that! |
Ok, I've found the real issue: QueryRow assumes there will be only one row, and closes the uderlying Connection right after Scan. |
Minimum program to reproduce:
Output:
The text was updated successfully, but these errors were encountered: