go-goracle / goracle

Go database/sql driver for connecting to Oracle Database, using the ODPI-C library
273 stars 43 forks source link

Possible Memory Fatal error on C library #139

Closed rvegas closed 5 years ago

rvegas commented 5 years ago

Hello, I was running tests tunning goracle's connection pool and using this connection URI:

...
"oracle://%s:%s@%s:%d/%s/?connectionClass=GORACLE&poolMinSessions=1&poolMaxSessions=100&poolIncrement=1",
...

If I run a test with 100 concurrent workers runinng queries it goes very well.

But as soon as I run 150+ workers (sometimes 120 is enough) I get hit with the following error (which belings to a gigantic error trace):

fatal error: unexpected signal during runtime execution
fatal error: unexpected signal during runtime execution
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x7feedd7d33b9]

runtime stack:
runtime.throw(0xbced4c, 0x2a)
    /usr/local/go/src/runtime/panic.go:608 +0x72
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:374 +0x2f2

goroutine 201075 [syscall]:
runtime.cgocall(0xa236e0, 0xc000ab0938, 0x29)
    /usr/local/go/src/runtime/cgocall.go:128 +0x5e fp=0xc000ab0900 sp=0xc000ab08c8 pc=0x40e03e
gopkg.in/goracle%2ev2._Cfunc_dpiPool_acquireConnection(0x7feed80a0970, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000348570, 0x0)
    _cgo_gotypes.go:4111 +0x4d fp=0xc000ab0938 sp=0xc000ab0900 pc=0x9418ed
gopkg.in/goracle%2ev2.(*conn).acquireConn.func3(0x7feed80a0970, 0x0, 0xc000000000, 0x0, 0xc000000000, 0x0, 0xc000348570, 0x7)
    /home/ricardovegas/go/pkg/mod/gopkg.in/goracle.v2@v2.11.0/drv.go:558 +0xc3 fp=0xc000ab0988 sp=0xc000ab0938 pc=0x96b193
gopkg.in/goracle%2ev2.(*conn).acquireConn(0xc0010b16c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/ricardovegas/go/pkg/mod/gopkg.in/goracle.v2@v2.11.0/drv.go:558 +0x1f6 fp=0xc000ab0ab8 sp=0xc000ab0988 pc=0x94c256
gopkg.in/goracle%2ev2.(*drv).openConn(0xc000094e40, 0xc0001c8189, 0x18, 0xc0001c81a2, 0x8, 0xc0002ff340, 0x3a, 0xc0001c81f6, 0x7, 0x0, ...)
    /home/ricardovegas/go/pkg/mod/gopkg.in/goracle.v2@v2.11.0/drv.go:427 +0x15e9 fp=0xc000ab0fe8 sp=0xc000ab0ab8 pc=0x94bde9
gopkg.in/goracle%2ev2.(*drv).Open(0xc000094e40, 0xc0001c8180, 0xb3, 0x51, 0xc000ab11a0, 0x40fee3, 0x60)
    /home/ricardovegas/go/pkg/mod/gopkg.in/goracle.v2@v2.11.0/drv.go:360 +0x120 fp=0xc000ab1140 sp=0xc000ab0fe8 pc=0x94a730
database/sql.dsnConnector.Connect(0xc0001c8180, 0xb3, 0xc788e0, 0xc000094e40, 0xc81840, 0xc001ba5c20, 0xc001a53e00, 0x0, 0xc001a53e00, 0xc001ba0000)
    /usr/local/go/src/database/sql/sql.go:637 +0x45 fp=0xc000ab1188 sp=0xc000ab1140 pc=0x91ca45
database/sql.(*dsnConnector).Connect(0xc00000dbc0, 0xc81840, 0xc001ba5c20, 0x436851, 0xbe6c78, 0xc000ab1250, 0x20)
    <autogenerated>:1 +0x73 fp=0xc000ab11e8 sp=0xc000ab1188 pc=0x92b593
database/sql.(*DB).conn(0xc0004ac240, 0xc81840, 0xc001ba5c20, 0x1, 0x1b, 0xc000ab1428, 0x47ceba)
    /usr/local/go/src/database/sql/sql.go:1177 +0x135 fp=0xc000ab13a0 sp=0xc000ab11e8 pc=0x91ea75
database/sql.(*DB).begin(0xc0004ac240, 0xc81840, 0xc001ba5c20, 0xc00033fc30, 0x874301, 0xc0000380b8, 0xadb820, 0x139a4c0)
    /usr/local/go/src/database/sql/sql.go:1641 +0x4f fp=0xc000ab1400 sp=0xc000ab13a0 pc=0x9223af
database/sql.(*DB).BeginTx(0xc0004ac240, 0xc81840, 0xc001ba5c20, 0xc00033fc30, 0x1a, 0xc00027a340, 0xc00108ae40)
    /usr/local/go/src/database/sql/sql.go:1623 +0x8b fp=0xc000ab1470 sp=0xc000ab1400 pc=0x92217b
scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql/internal/sql/repository/connection.(*connection).BeginTx(0xc00007b380, 0xc81840, 0xc001ba5c20, 0xc00033fc30, 0x0, 0xc00027a340, 0x1a)
    /home/ricardovegas/dev/sqldb/sqldb_sql/internal/sql/repository/connection/connectionpool.go:138 +0x51 fp=0xc000ab14b8 sp=0xc000ab1470 pc=0x9be141
scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql/internal/sql/repository/connection.(*session).BeginTx(0xc0006362d0, 0xc81800, 0xc0000380b8, 0xc7c800, 0xc000348568, 0x0, 0x0, 0x0, 0x0)
    /home/ricardovegas/dev/sqldb/sqldb_sql/internal/sql/repository/connection/session.go:468 +0x1ee fp=0xc000ab1550 sp=0xc000ab14b8 pc=0x9c13be
scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql/internal/sql/controllers.(*SQL).BeginTx(0xc0002440f0, 0xc81880, 0xc0002425d0, 0xc0007b0cc0, 0x0, 0x0, 0x0)
    /home/ricardovegas/dev/sqldb/sqldb_sql/internal/sql/controllers/sql.go:381 +0x2f7 fp=0xc000ab1608 sp=0xc000ab1550 pc=0x9cb3c7
scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql/internal/sql/api/server/v1.(*ServerSQL).BeginTransaction(0x139a4c0, 0xc81880, 0xc0002425d0, 0xc0007b0cc0, 0x139a4c0, 0x115, 0x0)
    /home/ricardovegas/dev/sqldb/sqldb_sql/internal/sql/api/server/v1/sqldb.go:167 +0xbd fp=0xc000ab1680 sp=0xc000ab1608 pc=0x9dfa1d
scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql_protobuf/pkg/protobuf/sqldb/sql/v1._sqldbSQL_BeginTransaction_Handler.func1(0xc81880, 0xc0002425d0, 0xb61540, 0xc0007b0cc0, 0xc0012976f0, 0x464330, 0xc001297738, 0xc001297740)
    /home/ricardovegas/go/pkg/mod/scm.live.es.nextgen.igrupocompany/connectors/sqldb_sql_protobuf@v2.0.0+incompatible/pkg/protobuf/sqldb/sql/v1/sqldb.pb.go:559 +0x86 fp=0xc000ab16c8 sp=0xc000ab1680 pc=0x9d6016

It seems to happen when the following line is executed (which belongs to the C library):

https://github.com/go-goracle/goracle/blob/master/odpi/src/dpiPool.c#L30

I'm using goracle v2.11.0, the Oracle server is running 18.3 and the oracle client installed in centos is the oracle-instantclient12.2-basic.x86_64

tgulacsi commented 5 years ago

I have no real idea at the moment, so please try it with master or at least with v2.12.2 - it has a newer ODPI and v2.12.1 fixed a missing drv lock (that's map access error not such SIGSEGV, though).

A minimal repro case would be lovely, too!

rvegas commented 5 years ago

Ok I'll try that.

I opened the issue also to see if this rang any bells regarding the ODPI versions. I'll try 2.12.1 and come back with more info.

Thanks.

rvegas commented 5 years ago

Just an update, it keeps happening with 2.12.1. I'll try to give you a minimal repro case.

tgulacsi commented 5 years ago

Can't you try v2.12.3 ? That's with the latest ODPI-C (v3.1.2).

rvegas commented 5 years ago

It seems to be fixed with v2.12.3.

Im closing this issue, thanks as usual for the support.