-
Notifications
You must be signed in to change notification settings - Fork 8
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
SDK can't restore connection after disconnection #22
Comments
I'm not a go developer, but curious: is it different in case of other databases? E.g. mysql, elasticsearch? I mean it is it a common practice at all to restore a connection? |
@sanikolaev the same example with using MySQL driver works as expected (driver not closes connection after error): package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
)
func main() {
db, err := sql.Open("mysql", "tcp(127.0.0.1:9366)/")
if err != nil {
panic(err)
}
defer db.Close()
for ;; {
results, err := db.Query("SELECT name FROM idx_movies WHERE MATCH('аватар') limit 10 offset 0")
if err != nil {
fmt.Println(err)
continue
}
for results.Next() {
var name string
_ = results.Scan(&name)
log.Printf(name)
}
}
} |
Interesting how it's implemented in the mysql driver? At first glance I can only see https://github.com/go-sql-driver/mysql/blob/master/statement.go#L101 : func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
return stmt.query(args)
}
func (stmt *mysqlStmt) query(args []driver.Value) (*binaryRows, error) {
...
if stmt.mc.closed.IsSet() {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
} nothing like a connection restore upon a failed request or any other kind of retry. |
@sanikolaev database/sql opens new connection if driver returns driver.ErrBadConn after two attempts. https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1716 |
SDK can't restore connection after disconnection
Just run this sample, make sure the results start showing up and restart manticore after few seconds. The connection will not be restored and the program will continue to give an error (write tcp 127.0.0.1:49914->127.0.0.1:9311: write: broken pipe) despite the fact that the Manticore is already available
The text was updated successfully, but these errors were encountered: