没有可用的缓冲区空间(已达到最大连接?)表单 Postgres EDB 驱动程序

发布于 2024-10-11 09:05:09 字数 2045 浏览 7 评论 0原文

我们在通过 java 应用程序连接到数据库时遇到异常。堆栈跟踪如下所示,

com.edb.util.PSQLException: The connection attempt failed.
 at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:189)
 at com.edb.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
 at com.edb.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:161)
 at com.edb.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
 at com.edb.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
 at com.edb.Driver.makeConnection(Driver.java:391)
 at com.edb.Driver.connect(Driver.java:266)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 ... 12 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(Unknown Source)
 at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
 at java.net.PlainSocketImpl.connect(Unknown Source)
 at java.net.SocksSocketImpl.connect(Unknown Source)
 at java.net.Socket.connect(Unknown Source)
 at java.net.Socket.connect(Unknown Source)
 at java.net.Socket.<init>(Unknown Source)
 at java.net.Socket.<init>(Unknown Source)
 at com.edb.core.PGStream.<init>(PGStream.java:70)
 at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:115)
 ... 20 more

当错误发生时,我们无法连接到互联网和数据库,不得不重新启动系统。但三天后,相同的代码(即连接到数据库时)再次出现错误。我们使用 netstat 检查 TCP 连接。但 TCP 连接数并不多,即尚未达到最大限制。

我们的应用程序有多个长时间运行的 Java 进程,它们汇集数据库连接(不超过 60 个)并使其保持活动状态以触发下一个查询(因为它必须每 2 秒轮询一次数据库)。我们的应用程序中的一些查询正在连接大型表(1000 万条记录)以获取相关数据。

我们使用以下系统和应用程序

  • Windows 2003 服务器 SP2
  • Java 1.6
  • Postgres Plus Advanced 服务器 8.4 数据库
  • edb-jdbc14.jar 驱动程序用于从 Java 连接 DB

我们使用 Postgres DB 的默认配置,除了增加连接从 100 到 120。

有人在 postgres edb 驱动程序中遇到过同样的错误吗?

有人可以帮助我们找到解决方案吗?

We are facing an exception while connecting to database through our java application. The stack trace is as follows

com.edb.util.PSQLException: The connection attempt failed.
 at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:189)
 at com.edb.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
 at com.edb.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:161)
 at com.edb.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
 at com.edb.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
 at com.edb.Driver.makeConnection(Driver.java:391)
 at com.edb.Driver.connect(Driver.java:266)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 ... 12 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(Unknown Source)
 at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
 at java.net.PlainSocketImpl.connect(Unknown Source)
 at java.net.SocksSocketImpl.connect(Unknown Source)
 at java.net.Socket.connect(Unknown Source)
 at java.net.Socket.connect(Unknown Source)
 at java.net.Socket.<init>(Unknown Source)
 at java.net.Socket.<init>(Unknown Source)
 at com.edb.core.PGStream.<init>(PGStream.java:70)
 at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:115)
 ... 20 more

When the error occured we were not able to connect to internet and DB and had to reboot the system. But the error occured again after 3 days at same code i.e while connecting to DB. We checked TCP connections using netstat. But there were not many TCP connections i.e it has not reached the max limit.

Our application has multiple long running Java processes that pools the DB connections (not more than 60) and keeps it alive for firing the next query (as it has to poll the DB every 2 seconds). Some of the queries in our application are joining large tables (10 million records) to get the related data.

We are using following System and applications

  • Windows 2003 server SP2
  • Java 1.6
  • Postgres Plus Advanced server 8.4 Database
  • edb-jdbc14.jar driver for connection DB from Java

We have used the default configuration of Postgres DB except increasing the connection to 120 from 100.

Has anybody encountred the same error with postgres edb driver?

Can anybody help us finding the solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当梦初醒 2024-10-18 09:05:09

这看起来像是客户端问题 - 它甚至无法连接到服务器。这不是 PostgreSQL 或 Advanced Server 在可用服务器连接耗尽时收到的错误。

问题要么出在客户端程序/JVM 的资源中,要么出在 EDB JDBC 驱动程序中的某个位置。如果您在 JVM 中找不到不正确的内容,并且由于您使用的是 PostgreSQL Plus Advanced Server,我建议您使用 EnterpriseDB 支持来获取其 JDBC 驱动程序的帮助。 (与 PostgreSQL 不同)

This looks like a client side problem - it never manages to even connect to the server. It is not the error you get from the PostgreSQL or Advanced Server when it runs out of available server connections.

The problem is either in the resources for your client program/JVM, or somewhere in the EDB JDBC driver. If you can't find something incorrect in your JVM, and since you're on PostgreSQL Plus Advanced Server, I would suggest you use EnterpriseDB support for help with their JDBC driver. (Which is different from the PostgreSQL one)

云胡 2024-10-18 09:05:09

这似乎是客户端 Windows 问题,不一定是代码问题。
请参考我对 stackoverflow 上类似问题的回答

This appears to be a client-side Windows issue, not necessarily a code issue.
Please refer to my answer to a similar question on stackoverflow

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文