简体   繁体   English

连接到 Amazon RDS Oracle 实例时如何处理“从读取调用中得到减一”错误

[英]How to approach a "Got minus one from a read call" error when connecting to an Amazon RDS Oracle instance

I'm running Oracle 11GR2 on an Amazon RDS instance.我在 Amazon RDS 实例上运行 Oracle 11GR2。 occasionally I get an IO Error: Got minus one from a read call when making a call to DriverManager.getConnection(getUrl()) and I'm not sure why.有时我会收到IO Error: Got minus one from a read call在调用DriverManager.getConnection(getUrl())时从读取调用中得到减一,我不知道为什么。 Other applications work correctly.其他应用程序正常工作。

To further confuse things, the error will correct itself on occasion (following next iteration of the program).为了进一步混淆事情,错误有时会自行纠正(在程序的下一次迭代之后)。

How should I approach a "Got minus one from a read call" error?我应该如何处理“从读取调用中得到减一”错误?

Full stack trace:完整的堆栈跟踪:

java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:243)
    at com.cwd.facile.db.Database.<init>(Database.java:44)
    at com.cwd.facile.ns.NetSuiteRequestBased.<init>(NetSuiteRequestBased.java:29)
    at com.cwd.facile.ns.CommonOperations.isInventoryItem(CommonOperations.java:205)
    at com.cwd.facile.ns.CommonOperations.findItemIdByName(CommonOperations.java:188)
    at com.cwd.facile.ns.CommonOperations.createSalesOrder(CommonOperations.java:970)
    at com.cwd.facile.Main.main(Main.java:47)
Caused by: oracle.net.ns.NetException: Got minus one from a read call
    at oracle.net.ns.Packet.receive(Packet.java:311)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:300)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
    ... 12 more

Database.java line 44: setConn(DriverManager.getConnection(getUrl())); Database.java 第 44 行: setConn(DriverManager.getConnection(getUrl()));

Other info:其他信息:

  • I thought it was a bad JDBC url, but it does work, sometimes for days on end before failing.我认为这是一个糟糕的 JDBC url,但它确实有效,有时在失败之前连续几天。
  • Amazon RDS is a managed instance and configuration changes may not be possible Amazon RDS 是托管实例,可能无法更改配置
  • I am using ojdbc6.jar for connectivity我正在使用 ojdbc6.jar 进行连接

The immediate cause of the problem is that the JDBC driver has attempted to read from a network Socket that has been closed by "the other end".问题的直接原因是 JDBC 驱动程序试图从已被“另一端”关闭的网络 Socket 中读取数据。

This could be due to a few things:这可能是由于以下几点:

  • If the remote server has been configured (eg in the "SQLNET.ora" file) to not accept connections from your IP.如果远程服务器已配置(例如在“SQLNET.ora”文件中)不接受来自您 IP 的连接。

  • If the JDBC url is incorrect, you could be attempting to connect to something that isn't a database.如果 JDBC url 不正确,您可能正在尝试连接到不是数据库的东西。

  • If there are too many open connections to the database service, it could refuse new connections.如果与数据库服务的打开连接过多,它可能会拒绝新连接。

Given the symptoms, I think the "too many connections" scenario is the most likely.鉴于这些症状,我认为“连接过多”的情况最有可能。 That suggests that your application is leaking connections;这表明您的应用程序正在泄漏连接; ie creating connections and then failing to (always) close them.即创建连接,然后未能(总是)关闭它们。

We faced the same issue and fixed it.我们遇到了同样的问题并修复了它。 Below is the reason and solution.下面是原因和解决方法。

Problem问题

When the connection pool mechanism is used, the application server (in our case, it is JBOSS) creates connections according to the min-connection parameter.当使用连接池机制时,应用服务器(在我们的例子中是 JBOSS)根据min-connection参数创建连接。 If you have 10 applications running, and each has a min-connection of 10, then a total of 100 sessions will be created in the database.如果您有 10 个应用程序在运行,并且每个应用程序的min-connection为 10,那么将在数据库中创建总共 100 个会话。 Also, in every database, there is a max-session parameter, if your total number of connections crosses that border, then you will get Got minus one from a read call .此外,在每个数据库中,都有一个max-session参数,如果您的连接总数越过该边界,那么您将从Got minus one from a read call得到Got minus one from a read call

FYI: Use the query below to see your total number of sessions:仅供参考:使用下面的查询来查看您的会话总数:

SELECT username, count(username) FROM v$session 
WHERE username IS NOT NULL group by username

Solution: With the help of our DBA, we increased that max-session parameter, so that all our application min-connection can accommodate.解决方案:在我们的 DBA 的帮助下,我们增加了max-session参数,以便我们所有的应用程序min-connection都可以容纳。

I got this error message from using an oracle database in a docker despite the fact i had publish port to host option "-p 1521:1521".尽管我已将端口发布到主机选项“-p 1521:1521”,但我还是通过在 docker 中使用 oracle 数据库收到此错误消息。 I was using jdbc url that was using ip address 127.0.0.1, i changed it to the host machine real ip address and everything worked then.我使用的是使用 ip 地址 127.0.0.1 的 jdbc url,我将其更改为主机真实 ip 地址,然后一切正常。

I would like to augment to Stephen C's answer, my case was on the first dot.我想补充斯蒂芬 C 的回答,我的情况在第一个点上。 So since we have DHCP to allocate IP addresses in the company, DHCP changed my machine's address without of course asking neither me nor Oracle.所以既然我们有DHCP来分配公司的IP地址,DHCP就改变了我机器的地址,当然既不问我也不问Oracle。 So out of the blue oracle refused to do anything and gave the minus one dreaded exception.因此,出乎意料的 oracle 拒绝做任何事情,并给出了一个可怕的例外。 So if you want to workaround this once and for ever, and since TCP.INVITED_NODES of SQLNET.ora file does not accept wildcards as stated here , you can add you machine's hostname instead of the IP address.因此,如果您想一劳永逸地解决此问题,并且由于 SQLNET.ora 文件的 TCP.INVITED_NODES 不接受此处所述的通配符,您可以添加您机器的主机名而不是 IP 地址。

就我而言,我遇到了同样的异常,因为我在应用程序中配置的用户在数据库中不存在,创建用户并授予所需的权限解决了问题。

Cause原因

oracle binary permission issue ($ORACLE_HOME/bin/oracle) oracle 二进制权限问题 ($ORACLE_HOME/bin/oracle)

[tst19c@exa033dbadm01 bin]$ $ORACLE_HOME/bin [tst19c@exa033dbadm01 bin]$ $ORACLE_HOME/bin

[tst19c@exa033dbadm01 bin]$ ls -ltr oracle [tst19c@exa033dbadm01 bin]$ ls -ltr oracle

-rwxr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle -rwxr-s--x 1 tst19c asmadmin 446528768 5 月 3 日 14:28 oracle

Action Taken所采取的行动

[tst19c@exa033dbadm01 bin]$ chmod 6751 oracle [tst19c@exa033dbadm01 bin]$ chmod 6751 oracle

[tst19c@exa033dbadm01 bin]$ ls -ltr oracle [tst19c@exa033dbadm01 bin]$ ls -ltr oracle

Now现在

-rwsr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle -rwsr-s--x 1 tst19c asmadmin 446528768 5 月 3 日 14:28 oracle

[tst19c@exa033dbadm01 bin]$ [tst19c@exa033dbadm01 bin]$

I had a similar issue when running Oracle 21c XE image on Docker locally when I was trying to connect to it by localhost or 127.0.0.1 .当我尝试通过localhost127.0.0.1本地Docker 上运行Oracle 21c XE映像时,我遇到了类似的问题。

The fix was to log in into the container and modify sqlnet.ora in the following way:修复方法是登录容器并按以下方式修改sqlnet.ora

echo "DISABLE_OOB=ON" >> /opt/oracle/oradata/dbconfig/XE/sqlnet.ora

and restart the container.并重新启动容器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在与Oracle数据库连接的Java应用程序中发现问题,SQLException:Io异常:从读取调用中减去一个,我该如何解决? - Found issue in java application connecting with oracle database,SQLException: Io exception: Got minus one from a read call ,how I can solve it? 在连接到oracle 10g数据库时,获取IOException“从读取调用中减去一个” - getting IOException “got minus one from a read call” while connecting to oracle 10g database 如何解决从 oracle 11g jdbc 7/14 jdk 1.7 中的读取调用中得到减一? - how to resolve Got minus one from a read call in oracle 11g jdbc 7/14 jdk 1.7? IO错误:从读取调用中减去一个 - IO Error: Got minus one from a read call java.sql.SQLException:Io异常:在与oracle的JDBC连接期间从读取调用中减去了一个 - java.sql.SQLException: Io exception: Got minus one from a read call during JDBC connection with oracle java.sql.SQLException:Io异常:在与oracle 11g进行JDBC连接期间,从读取调用中减去了一个 - java.sql.SQLException: Io exception: Got minus one from a read call during JDBC connection with oracle 11g 使用 Java 连接到 Amazon RDS 实例时如何解决 ORA-12514 - How can I resolve an ORA-12514 when connecting to an Amazon RDS instance using Java 在 python 中连接到 AWS RDS MySQL 服务时出错 - Got error when connecting to AWS RDS MySQL service in python 桌面应用程序连接到远程Amazon RDS mysql实例 - Desktop app connecting to a remote Amazon RDS mysql instance 在连接到Amazon RDS时被阻止 - Blocked on connecting to Amazon RDS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM