kawansoft / aceql-http

AceQL HTTP is a framework of REST like http APIs that allow to access to remote SQL databases over http from any device that supports http.
https://www.aceql.com
Other
97 stars 20 forks source link

PoolExhaustedException #10

Closed santhosh250595 closed 4 years ago

santhosh250595 commented 4 years ago

Hello, I'm getting the below error when I try to establish connection and execute some commands in postgres using AceQL Server in local and started as a server. Kindly give some suggestions here.

org.apache.tomcat.jdbc.pool.PoolExhaustedException: [pool-57-thread-3] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:50; busy:50; idle:0; lastwait:30000]. at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:710) at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198) at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:132) at org.kawanfw.sql.api.server.DefaultDatabaseConfigurator.getConnection(DefaultDatabaseConfigurator.java:126) at org.kawanfw.sql.servlet.ServerLoginActionSql.getConnectionId(ServerLoginActionSql.java:200) at org.kawanfw.sql.servlet.ServerLoginActionSql.executeAction(ServerLoginActionSql.java:165) at org.kawanfw.sql.servlet.ServerSqlDispatch.executeRequestInTryCatch(ServerSqlDispatch.java:123) at org.kawanfw.sql.servlet.ServerSqlManager.handleRequest(ServerSqlManager.java:477) at org.kawanfw.sql.servlet.ServerSqlManager.handleRequestWrapper(ServerSqlManager.java:244) at org.kawanfw.sql.servlet.ServerSqlManager.access$0(ServerSqlManager.java:241) at org.kawanfw.sql.servlet.ServerSqlManager$1.run(ServerSqlManager.java:224) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

ndepomereu commented 4 years ago

Hi, Make sure to close the Connection on the client side after usage, otherwise the connection pool will get exhausted.

The default AceQL configuration on the server never close Connections that have not been explicitly closed by remote client users (C#, Java, Python, etc).

This means it is required that the client-side calls aConnection.close()(or equivalent in C# and Python) in order to release a remote JDBC Connection so that it is put back in the pool and available for other users.

This default behavior may be changed by using two Tomcat JDBC Pool properties: removeAbandoned& removeAbandonedTimeout.

Activate the following lines in your aceql-server.properties(replace sampledb by you database name) and Connections will be released automatically after the defined timeout:

# The removeAbandoned & removeAbandonedTimeout Properties allow to
# remove automatically the abandoned connections so that they 
# are recycled in the pool and will be available for other client users. 
# removeAbandonedTimeout defines the timeout in seconds before the removal.
# These settings are useful in order to avoid connection pool exhaustion 
# when client user programs in C#, Java or Python don't close explicitly 
# their connection.
# Just set removeAbandoned=true for your database and abandoned connections
# will thus be recycled in the connection pool after removeAbandonedTimeout 
# seconds.
# See http://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html#Common_Attributes
# for more info and for other important properties.

sampledb.removeAbandoned=true
sampledb.removeAbandonedTimeout=120

(Please note that this will have an impact on the behavior of client applications: AeQL Connections will be brutally “cut” after 120 seconds, and a new Connection will then have to be re-created.)

Please note that the org.kawanfw.sql.api.server.DefaultPoolsInfoservlet allows to monitor the state of the Tomcat JDBC Pool in order to know how many client users are connected, how many Connections are available in the pool, etc. See the bottom of aceql-server.properties and the DefaultPoolsInfoJavadoc for more info.

ndepomereu commented 4 years ago

Hi, I close the issue. Do not hesitate to contact me if more info needed on the subject.