Error on begin transaction in go-pg v9.2.0

198 Views Asked by At

I have updated go-pg lib from v9.0.3 to v9.2.0.

Getting error:

panic: not reached [recovered]
        panic: not reached

        /usr/local/go/src/runtime/panic.go:969 +0x175
github.com/go-pg/pg/v9/internal/pool.(*SingleConnPool).SetConn(...)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/internal/pool/pool_single.go:61
github.com/go-pg/pg/v9.(*baseDB).initConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0xc000292550, 0x0, 0x0)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:115 +0x585
github.com/go-pg/pg/v9.(*baseDB).getConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0x0, 0x0, 0x0)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:79 +0x90
github.com/go-pg/pg/v9.(*baseDB).withConn(0xc0002440f0, 0x1efb500, 0xc00019e008, 0xc000813c00, 0x0, 0x0)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/base.go:133 +0x7c
github.com/go-pg/pg/v9.(*Tx).withConn(...)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:96
github.com/go-pg/pg/v9.(*Tx).exec(0xc00072c980, 0x1efb500, 0xc00019e008, 0x1bd4d20, 0x1ec3250, 0x0, 0x0, 0x0, 0x8, 0xc000078cd0, ...)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:149 +0x1f0
github.com/go-pg/pg/v9.(*Tx).ExecContext(...)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:139
github.com/go-pg/pg/v9.(*Tx).begin(0xc00072c980, 0x1efb500, 0xc00019e008, 0x4b2, 0x0)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:339 +0xb6
github.com/go-pg/pg/v9.(*baseDB).Begin(0xc000244000, 0x25f0b4e, 0x24, 0xc000589ea0)
        /Users/sanches1984/go/src/github.com/sanches1984/statclass/vendor/github.com/go-pg/pg/v9/tx.go:53 +0x1ca
github.com/sanches1984/gopkg-database.(*dbWrapper).StartTransaction(0xc0007180c0, 0x0, 0x25f0b4e, 0x24, 0xc0000003f3)

Fail on:

tx, err := conn.Begin()

Found that they fix it here, but it doesn't work. What's the problem?

1

There are 1 best solutions below

1
On BEST ANSWER

Check first if this is linked to go-pg/pg issue 1687, which is supposed to be resolved in PR 1688.

That PR is only available in v10.0.0-beta.9, so you would need to explicitly upgrade your dependency

go get github.com/go-pg/[email protected]