有对 oracle 熟悉的老哥吗? 求指导一个问题

2022-08-30 13:55:27 +08:00
 scalaer

java jdbc 连接 oracle, 偶尔会出现下面这个错误。

Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset by peer, connect lapse 9 ms., Authentication lapse 0 ms.
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:794)
	at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	... 9 more
Caused by: java.io.IOException: Connection reset by peer, connect lapse 9 ms., Authentication lapse 0 ms.
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:790)
	... 17 more
Caused by: java.io.IOException: Connection reset by peer, connect lapse 9 ms.
	at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:138)
	at oracle.net.ns.NSProtocol.connect(NSProtocol.java:317)
	at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518)
	... 17 more
Caused by: java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:197)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at oracle.net.nt.TimeoutSocketChannel.read(TimeoutSocketChannel.java:168)
	at oracle.net.ns.NIOHeader.readHeaderBuffer(NIOHeader.java:82)
	at oracle.net.ns.NIOPacket.readNIOPacket(NIOPacket.java:252)
	at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:118)

报错信息从网上搜索的答案都是 oracle 连接数不够了, 但是写了一个测试程序, 申请的连接数大于 oracle 的最大连接数,无法触发相同的错误, 想请教下如何 100%触发这个报错

986 次点击
所在节点    问与答
7 条回复
imzcg2
2022-08-30 14:14:25 +08:00
scalaer
2022-08-30 14:20:04 +08:00
@imzcg2 根据这些解决方案反推, 触发问题, 没有触发
imzcg2
2022-08-30 14:40:46 +08:00
https://www.jianshu.com/p/b5dfaffb474d
再试一下吧

alter profile DEFAULT limit idle_time UNLIMITED;

connect time
imzcg2
2022-08-30 14:41:36 +08:00
把 UNLIMITED 改成一分钟 idle_time 改成 connect_time,估计很快就炸了(触发)
imzcg2
2022-08-30 14:44:05 +08:00
time-between-eviction-runs-millis: 5000(5 秒)
如果有要把 5000 改成大于你刚刚设计的时间,不让客户端保活,炸的更快
scalaer
2022-08-30 15:01:52 +08:00
@imzcg2 不行, 这两个改成 1 了, 也没触发

DEFAULT,IDLE_TIME,KERNEL,1
DEFAULT,CONNECT_TIME,KERNEL,1
scalaer
2022-08-30 15:06:02 +08:00
客户端的逻辑

```java
Connection conn = DriverManager.getConnection(xxx);

// sleep 70s
Thread.sleep(1000 * 70);

Statement stmt = conn.createStatement();
```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/876463

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX