-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Panic when client receive redirect packet #23
Comments
if you receive redirect packet this means error |
this code work correct without error return result: X
|
try to call db.Ping first before query to see if it is connected |
Hi sijms, Using your code and including only db.Ping, as you suggest, I still getting error message. I've created the file test.go to validate the code that you've sent. test.go package main
import (
"database/sql"
"fmt"
_ "github.com/sijms/go-ora"
)
func main() {
conn, err := sql.Open("oracle", "oracle://user:pass@server:1521/service")
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
err = conn.Ping()
if err != nil {
fmt.Println(err)
return
}
stmt, err := conn.Prepare("select * from dual where 1 = :1")
if err != nil {
fmt.Println(err)
return
}
defer stmt.Close()
results, err := stmt.Query(1)
if err != nil {
fmt.Println(err)
return
}
defer results.Close()
var temp string
for results.Next() {
err = results.Scan(&temp)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("results: ", temp)
}
if err = results.Err(); err != nil {
fmt.Println(err)
return
}
return
} Error: panic: runtime error: slice bounds out of range [:315] with capacity 16
goroutine 1 [running]:
github.com/sijms/go-ora/network.newRedirectPacketFromData(0xc00001e4d0, 0xa, 0x10, 0xa)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/redirect_packet.go:41 +0x294
github.com/sijms/go-ora/network.(*Session).readPacket(0xc00000c1e0, 0x5f5be0, 0xc000001e00, 0x0, 0x0)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/session.go:272 +0xaf8
github.com/sijms/go-ora/network.(*Session).Connect(0xc00000c1e0, 0xc00000c1e0, 0xc)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/session.go:76 +0x29a
github.com/sijms/go-ora.(*Connection).Open(0xc00011e140, 0x3e, 0xc00011e140)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/connection.go:232 +0x185
github.com/sijms/go-ora.(*oracleDriver).Open(0x82f180, 0x5ca80e, 0x3e, 0x0, 0x0, 0x203000, 0x200000)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/connection.go:79 +0x77
database/sql.dsnConnector.Connect(...)
/usr/local/go/src/database/sql/sql.go:707
database/sql.(*DB).conn(0xc00007edd0, 0x5f7040, 0xc00001e0f0, 0xc00000e001, 0x0, 0xc000055d00, 0x0)
/usr/local/go/src/database/sql/sql.go:1294 +0x204
database/sql.(*DB).PingContext(0xc00007edd0, 0x5f7040, 0xc00001e0f0, 0x3e, 0xc00007edd0)
/usr/local/go/src/database/sql/sql.go:799 +0x90
database/sql.(*DB).Ping(...)
/usr/local/go/src/database/sql/sql.go:817
main.main()
/home/rodrigo/myProject/test.go:16 +0x158
exit status 2 Oracle Version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
"CORE 12.1.0.2.0 Production"
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production |
Hi imrodrigoit, I faced similar issue but couldn't reproduce anymore (#6) |
now the error in ping this means the error occur during connect if you can help and print the data received from the server (redirect packet) |
Hi, @fleshin , I'm using RAC. [0 10 0 0 5 2 0 0 1 49]
panic: runtime error: slice bounds out of range [:315] with capacity 16
goroutine 1 [running]:
github.com/sijms/go-ora/network.newRedirectPacketFromData(0xc000108020, 0xa, 0x10, 0xa)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/redirect_packet.go:43 +0x33b
github.com/sijms/go-ora/network.(*Session).readPacket(0xc0000d2000, 0x5f5c20, 0xc000112000, 0x0, 0x0)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/session.go:272 +0xaf8
github.com/sijms/go-ora/network.(*Session).Connect(0xc0000d2000, 0xc0000d2000, 0xc)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/network/session.go:76 +0x29a
github.com/sijms/go-ora.(*Connection).Open(0xc0000cc140, 0x3e, 0xc0000cc140)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/connection.go:232 +0x185
github.com/sijms/go-ora.(*oracleDriver).Open(0x82f180, 0x5ca80e, 0x3e, 0x0, 0x0, 0x203000, 0x200000)
/home/rodrigo/myProject/vendor/github.com/sijms/go-ora/connection.go:79 +0x77
database/sql.dsnConnector.Connect(...)
/usr/local/go/src/database/sql/sql.go:707
database/sql.(*DB).conn(0xc00009ec30, 0x5f7080, 0xc0000a2000, 0xc0000ae001, 0x0, 0xc000050d00, 0x0)
/usr/local/go/src/database/sql/sql.go:1294 +0x204
database/sql.(*DB).PingContext(0xc00009ec30, 0x5f7080, 0xc0000a2000, 0x3e, 0xc00009ec30)
/usr/local/go/src/database/sql/sql.go:799 +0x90
database/sql.(*DB).Ping(...)
/usr/local/go/src/database/sql/sql.go:817
main.main()
/home/rodrigo/myProject/test.go:16 +0x158
exit status 2 |
Thank you so much for the update. |
Hi @sijms Sorry, but I,ve tested using a DB that is not in RAC, but using a DB in RAC, I still getting error. panic: runtime error: slice bounds out of range [:315] with capacity 16 goroutine 1 [running]: |
stillthe problem is server send redirect packet 10 bytes long then send data packet that contains the redirect data. |
the redirect packet only available with oracle RAC |
Yes, sure. No problem. |
I make a commit for test redirect packet as follow: after reading data I make 3 print
|
I think the issue is now solved |
Hi @sijms , Sorry the delay. data returned: (ADDRESS=(PROTOCOL=TCP)(HOST=87.87.87.87)(PORT=1521))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host.com:1521)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myService)(CID=(PROGRAM=/tmp/go-build664283631/b001/exe/go_ora)(HOST=rodrigo-bold)(USER=rodrigo))(SERVER=dedicated)(INSTANCE_NAME=myService))) |
Bug fixed |
Hi @sijms , Thank You so much for your help. Now it's working! data returned: (ADDRESS=(PROTOCOL=TCP)(HOST=87.87.87.87)(PORT=1521))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host.com:1521)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myService)(CID=(PROGRAM=/tmp/go-build017102808/b001/exe/testGoOra)(HOST=rodrigo-bold)(USER=rodrigo))(SERVER=dedicated)(INSTANCE_NAME=myService2))) Successfully connected. X |
Hi,
Aftter create a connection and open, I'm getting error at prepare statement.
My Connection function:
My Work function:
Error:
Thanks!
The text was updated successfully, but these errors were encountered: