Skip to content
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

After the client connects to oracle for a period of time, an error is reported during the operation: Not data packet #240

Closed
younglifestyle opened this issue Sep 8, 2022 · 3 comments

Comments

@younglifestyle
Copy link

younglifestyle commented Sep 8, 2022

oracle version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
Golang : go 1.18 database/sql go-ora 2.5.3

use native *sql.DB.

	conn, err := sql.Open("oracle", c.Oracle.Source)
	if err != nil {
		panic("Can't open the driver: " + err.Error())
	}

	err = conn.Ping()
	if err != nil {
		panic("Can't ping connection: " + err.Error())
	}
	conn.SetMaxIdleConns(10)
	conn.SetConnMaxIdleTime(14400)
	conn.SetMaxOpenConns(30)

comparative test of go-oci8+xorm, there is no situation that the connection cannot be used after being idle for a period of time

Trace Log:

2022-09-09T14:37:47.4691: 
Write packet:
00000000  01 24 00 00 06 00 00 00  00 00 03 5e 00 02 81 21  |.$.........^...!|
00000010  00 01 01 e1 01 01 0d 00  00 00 00 04 7f ff ff ff  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  |................|
00000030  00 e1 49 4e 53 45 52 54  20 49 4e 54 4f 20 6d 6f  |..INSERT INTO mo|
00000040  5f 69 6e 66 6f 20 28 77  6f 72 6b 5f 6f 72 64 65  |_info (work_orde|
00000050  72 2c 6d 6f 2c 66 61 63  74 6f 72 79 2c 66 6c 6f  |r,mo,factory,flo|
00000060  77 5f 69 64 2c 66 6c 6f  77 5f 73 74 65 70 5f 69  |w_id,flow_step_i|
00000070  6e 64 65 78 2c 66 6c 6f  77 5f 73 74 65 70 5f 6e  |ndex,flow_step_n|
00000080  61 6d 65 2c 66 6c 6f 77  5f 73 74 65 70 5f 63 6f  |ame,flow_step_co|
00000090  64 65 2c 66 6c 6f 77 5f  73 74 65 70 5f 73 74 61  |de,flow_step_sta|
000000a0  74 65 2c 62 69 6e 31 2c  6e 6f 74 5f 62 69 6e 31  |te,bin1,not_bin1|
000000b0  2c 63 75 72 72 65 6e 74  5f 72 65 6a 65 63 74 5f  |,current_reject_|
000000c0  6e 6f 2c 63 75 72 72 65  6e 74 5f 6d 6f 64 69 66  |no,current_modif|
000000d0  79 5f 61 63 74 69 6f 6e  29 20 56 41 4c 55 45 53  |y_action) VALUES|
000000e0  20 28 27 31 32 33 27 2c  27 32 32 33 27 2c 27 31  | ('123','223','1|
000000f0  32 33 27 2c 27 32 31 33  27 2c 27 32 34 27 2c 27  |23','213','24','|
00000100  34 34 27 2c 27 33 33 27  2c 30 2c 30 2c 30 2c 30  |44','33',0,0,0,0|
00000110  2c 30 29 01 01 01 01 00  00 00 00 00 00 00 02 80  |,0).............|
00000120  00 00 00 00                                       |....|
2022-09-09T14:37:47.4692: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|

trace log under normal conditions::

Write packet:
00000000  01 24 00 00 06 00 00 00  00 00 03 5e 00 02 81 21  |.$.........^...!|
00000010  00 01 01 e1 01 01 0d 00  00 00 00 04 7f ff ff ff  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  |................|
00000030  00 e1 49 4e 53 45 52 54  20 49 4e 54 4f 20 6d 6f  |..INSERT INTO mo|
00000040  5f 69 6e 66 6f 20 28 77  6f 72 6b 5f 6f 72 64 65  |_info (work_orde|
00000050  72 2c 6d 6f 2c 66 61 63  74 6f 72 79 2c 66 6c 6f  |r,mo,factory,flo|
00000060  77 5f 69 64 2c 66 6c 6f  77 5f 73 74 65 70 5f 69  |w_id,flow_step_i|
00000070  6e 64 65 78 2c 66 6c 6f  77 5f 73 74 65 70 5f 6e  |ndex,flow_step_n|
00000080  61 6d 65 2c 66 6c 6f 77  5f 73 74 65 70 5f 63 6f  |ame,flow_step_co|
00000090  64 65 2c 66 6c 6f 77 5f  73 74 65 70 5f 73 74 61  |de,flow_step_sta|
000000a0  74 65 2c 62 69 6e 31 2c  6e 6f 74 5f 62 69 6e 31  |te,bin1,not_bin1|
000000b0  2c 63 75 72 72 65 6e 74  5f 72 65 6a 65 63 74 5f  |,current_reject_|
000000c0  6e 6f 2c 63 75 72 72 65  6e 74 5f 6d 6f 64 69 66  |no,current_modif|
000000d0  79 5f 61 63 74 69 6f 6e  29 20 56 41 4c 55 45 53  |y_action) VALUES|
000000e0  20 28 27 31 32 33 27 2c  27 32 32 33 27 2c 27 31  | ('123','223','1|
000000f0  32 33 27 2c 27 32 31 33  27 2c 27 32 34 27 2c 27  |23','213','24','|
00000100  34 34 27 2c 27 33 33 27  2c 30 2c 30 2c 30 2c 30  |44','33',0,0,0,0|
00000110  2c 30 29 01 01 01 01 00  00 00 00 00 00 00 02 80  |,0).............|
00000120  00 00 00 00                                       |....|
2022-09-09T13:43:36.9241: 
Read packet:
00000000  00 54 00 00 06 00 00 00  00 00 08 01 06 03 c2 71  |.T.............q|
00000010  47 00 01 02 01 02 00 00  00 00 00 04 01 05 01 08  |G...............|
00000020  01 01 00 00 00 01 02 01  0c 02 00 00 00 00 00 03  |................|
00000030  01 9a 53 01 05 00 02 04  8b 01 03 00 00 00 00 01  |..S.............|
00000040  01 01 0d 0d 01 00 01 9a  53 00 05 00 00 04 8b 00  |........S.......|
00000050  03 00 00 00                                       |....|
2022-09-09T13:43:36.9253: Summary: RetCode:0, Error Message:""

@younglifestyle
Copy link
Author

younglifestyle commented Sep 9, 2022

if len(packetData) <= 0xA || PacketType(packetData[4]) != DATA {

At present, I directly change the code here to

if len(packetData) < 0xA || PacketType(packetData[4]) != DATA {

but I don't know if it will cause other problems.

Trace Log:

2022-09-09T16:14:54.3554: 
Write packet:
00000000  01 24 00 00 06 00 00 00  00 00 03 5e 00 02 81 21  |.$.........^...!|
00000010  00 01 01 e1 01 01 0d 00  00 00 00 04 7f ff ff ff  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  |................|
00000030  00 e1 49 4e 53 45 52 54  20 49 4e 54 4f 20 6d 6f  |..INSERT INTO mo|
00000040  5f 69 6e 66 6f 20 28 77  6f 72 6b 5f 6f 72 64 65  |_info (work_orde|
00000050  72 2c 6d 6f 2c 66 61 63  74 6f 72 79 2c 66 6c 6f  |r,mo,factory,flo|
00000060  77 5f 69 64 2c 66 6c 6f  77 5f 73 74 65 70 5f 69  |w_id,flow_step_i|
00000070  6e 64 65 78 2c 66 6c 6f  77 5f 73 74 65 70 5f 6e  |ndex,flow_step_n|
00000080  61 6d 65 2c 66 6c 6f 77  5f 73 74 65 70 5f 63 6f  |ame,flow_step_co|
00000090  64 65 2c 66 6c 6f 77 5f  73 74 65 70 5f 73 74 61  |de,flow_step_sta|
000000a0  74 65 2c 62 69 6e 31 2c  6e 6f 74 5f 62 69 6e 31  |te,bin1,not_bin1|
000000b0  2c 63 75 72 72 65 6e 74  5f 72 65 6a 65 63 74 5f  |,current_reject_|
000000c0  6e 6f 2c 63 75 72 72 65  6e 74 5f 6d 6f 64 69 66  |no,current_modif|
000000d0  79 5f 61 63 74 69 6f 6e  29 20 56 41 4c 55 45 53  |y_action) VALUES|
000000e0  20 28 27 31 32 33 27 2c  27 32 32 33 27 2c 27 31  | ('123','223','1|
000000f0  32 33 27 2c 27 32 31 33  27 2c 27 32 34 27 2c 27  |23','213','24','|
00000100  34 34 27 2c 27 33 33 27  2c 30 2c 30 2c 30 2c 30  |44','33',0,0,0,0|
00000110  2c 30 29 01 01 01 01 00  00 00 00 00 00 00 02 80  |,0).............|
00000120  00 00 00 00                                       |....|
2022-09-09T16:14:54.3559: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3559: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3559: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3566: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3566: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3571: 
Read packet:
00000000  00 0a 00 00 06 10 00 00  00 00                    |..........|
2022-09-09T16:14:54.3767: 
Read packet:
00000000  00 54 00 00 06 00 00 00  00 00 08 01 06 03 c2 8a  |.T..............|
00000010  44 00 01 02 01 02 00 00  00 00 00 04 01 05 01 0e  |D...............|
00000020  01 01 00 00 00 01 02 01  0c 02 00 00 00 00 00 03  |................|
00000030  01 9a 53 01 05 00 02 04  8b 01 06 00 00 00 00 01  |..S.............|
00000040  01 01 0d 0d 01 00 01 9a  53 00 05 00 00 04 8b 00  |........S.......|
00000050  06 00 00 00                                       |....|
2022-09-09T16:14:54.3771: Summary: RetCode:0, Error Message:""
2022-09-09T16:14:54.3771: 
Write packet:
00000000  00 15 00 00 06 00 00 00  00 00 11 69 00 01 01 01  |...........i....|
00000010  01 02 03 93 00                                    |.....|
2022-09-09T16:14:54.3926: 
Read packet:
00000000  00 0f 00 00 06 00 00 00  00 00 09 01 05 01 10     |...............|

@mgasparic
Copy link

I am getting the same error on go 1.19 go-ora 2.5.3, connecting to Oracle ATP. Would appreciate the solution very much!

@sijms
Copy link
Owner

sijms commented Nov 18, 2022

no problem if you change the condition form

if len(packetData) <= 0xA

to

if len(packetData) < 0xA

this will read an empty data packet and will repeat reading until server send some information
I will add your solution in next release

@sijms sijms closed this as completed Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants