Giter VIP home page Giter VIP logo

mssqlx's Issues

Segfault because of null-pointer when Connect fails

I was hoping to make our application more resilient against db outages, but when one of the dsns is down during initial connect the first query will trigger a segfault:

github.com/linxGnu/mssqlx._query.func1(0x6b2da8, 0xc000124200, 0xc000140060, 0xc0000fd858)
        /home/jasper/go/pkg/mod/github.com/linx!gnu/[email protected]/mssqlx.go:682 +0x3b
github.com/linxGnu/mssqlx.retryBackoff(0xc0000341e0, 0x48, 0xc0000fd8c0, 0x0, 0x16, 0x2, 0x16)
        /home/jasper/go/pkg/mod/github.com/linx!gnu/[email protected]/mssqlx.go:521 +0x65
github.com/linxGnu/mssqlx._query(0x9c5600, 0xc0000ae058, 0xc000106680, 0xc0000341e0, 0x48, 0x0, 0x0, 0x0, 0x48, 0xc000176280, ...)
        /home/jasper/go/pkg/mod/github.com/linx!gnu/[email protected]/mssqlx.go:681 +0x14a
github.com/linxGnu/mssqlx.(*DBs).Query(...)
        /home/jasper/go/pkg/mod/github.com/linx!gnu/[email protected]/mssqlx.go:702

I think it can be fixed by using sqlx.Open in ConnectMasterSlaves instead of sqlx.Connect here:

mssqlx/mssqlx.go

Line 1488 in 28aead0

dbConn, err := sqlx.Connect(driverName, masterDSNs[mId])
(and a few lines lower for the slaves).

QueryRow implementation is incorrect

func (dbs *DBs) QueryRow(query string, args ...interface{}) (r *sql.Row, err error) {

As per commenting on the function: "Errors are deferred until Row's Scan method is called."

This implementation mistake has been made with all variations of the "QueryRow" functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.