V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
scalaer
V2EX  ›  问与答

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

  •  
  •   scalaer · 2022-08-30 13:55:27 +08:00 · 985 次点击
    这是一个创建于 814 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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%触发这个报错

    imzcg2
        1
    imzcg2  
       2022-08-30 14:14:25 +08:00
    scalaer
        2
    scalaer  
    OP
       2022-08-30 14:20:04 +08:00
    @imzcg2 根据这些解决方案反推, 触发问题, 没有触发
    imzcg2
        3
    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
        4
    imzcg2  
       2022-08-30 14:41:36 +08:00
    把 UNLIMITED 改成一分钟 idle_time 改成 connect_time,估计很快就炸了(触发)
    imzcg2
        5
    imzcg2  
       2022-08-30 14:44:05 +08:00
    time-between-eviction-runs-millis: 5000(5 秒)
    如果有要把 5000 改成大于你刚刚设计的时间,不让客户端保活,炸的更快
    scalaer
        6
    scalaer  
    OP
       2022-08-30 15:01:52 +08:00
    @imzcg2 不行, 这两个改成 1 了, 也没触发

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

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

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

    Statement stmt = conn.createStatement();
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1022 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 19:37 · PVG 03:37 · LAX 11:37 · JFK 14:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.