Jboss Wildfly not closing connections when not in use - jboss

I am using jboss server with the following configurations timeout:-
<timeout>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>
<min-pool-size>10</min-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
Now, as soon as the server reaches the max load(30 connections) the datasource details obtained from jboss's CLI reports Active Count = 30 and Available Count = 30.
However, even after reducing the server request to 1, the active count and the Available Count report 30 as their values.
Expected :- The numbers should decrease and ideally only 1 connection from prefilled pool should be used instead of keeping all the connections awake!!
I am seeing the following logs :-
17:34:12,359 DEBUG [org.jboss.jca.core.connectionmanager.pool.idle.IdleRemover] (IdleRemover) Notifying pools, interval: 30000
Please help!

The connection pool implementation (ironjacamar) on WildFly 8 is in FIFO aka round robin manner. So having max-pool-size number of request within time of idle-timeout-minutes is enough to keep the pool from shrinking.
I have to use another decrementer policy to tell the connection pool to shrink for a size n explicitly for every idle-timeout-minutes interval.
Sample setting as below
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>false</prefill>
<use-strict-min>true</use-strict-min>
<capacity>
<decrementer class-name="org.jboss.jca.core.connectionmanager.pool.capacity.SizeDecrementer">
<config-property name="Size">
1
</config-property>
</decrementer>
</capacity>
</pool>
http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/ch05.html#deploying_capacity_policies

Related

max-pool-size for DB connections Keycloak version 11

Trying to investigate an issue regarding a keycloak deployment.
From the documentation we're seeing that we should alter this property in the stanealone.xml to allow more
However , after altering the standalone xml to this
</datasource>
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:postgresql://${env.DB_ADDR:postgres}/${env.DB_DATABASE:keycloak}${env.JDBC_PARAMS:}</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>200</max-pool-size>
</pool>
When we allow the JMX connection to the management console I notice this
max pool size showing 19
Is there anything which could be overriding the max-pool-size setting we're using or how would one go about debugging where is derives the max-pool-size if not from the standalone.xml
I don't know why exactly you get this issue but I'll try to help to the best of my abilities.
Keycloak 11 uses Widlfy 20, which offers several options to configure the datasource.
Please try to set
pool-use-strict-min to true
pool-prefill to true
min-pool-size to 200
initial-pool-size to 200
Also, monitor the number of opened connection on your Postgres database, and check if they recoup with the JMX report you got.
Finally, if none of these cause a change in your situation I can only suggest to try another ManagedConnectionPool implementation (see mcp attribute)

Spring Boot 1.5.3 Creating more connection than specified in application.properties

I am working on a project where i have dual datasource configured. On testing i have limit the no of max-active connections to five but when i checked on database, i found that application create around 25+ connections.
Code Sample
# Number of ms to wait before throwing an exception if no connection is available.
spring.datasource.tomcat.max-wait=1000
# Maximum number of active connections that can be allocated from this pool at the same time.
spring.datasource.tomcat.max-active=1
spring.datasource.tomcat.max-idle=1
spring.datasource.tomcat.min-idle=1
spring.datasource.tomcat.initial-size=1
# Validate the connection before borrowing it from the pool.
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-while-idle = true
spring.datasource.tomcat.validation-query = true
spring.datasource.tomcat.time-between-eviction-runs-millis = 360000
spring.rdatasource.tomcat.max-wait=1000
# Maximum number of active connections that can be allocated from this pool at the same time.
spring.rdatasource.tomcat.max-active=1
spring.rdatasource.tomcat.max-idle=1
spring.rdatasource.tomcat.min-idle=1
spring.rdatasource.tomcat.initial-size=1
# Validate the connection before borrowing it from the pool.
spring.rdatasource.tomcat.test-on-borrow=true
spring.rdatasource.tomcat.test-while-idle= true
spring.rdatasource.tomcat.validation-query = true
spring.rdatasource.tomcat.time-between-eviction-runs-millis = 360000
above connection is working fine, but exceeding no of connection to database. User which i am using is limited to 10 connection.
when i hit request to application than i am getting
query wait timeout error with unable to create initial pool size.
I am using tomcat connection pooling
Please provide me the solution so application will run with 10 connections limit which is set at database.

Database connection issue - App unable to recover

I have a Java EE Web App running on JBoss AS 7.2 connecting to a Postgresql 9.4 database (hosted on RDS).
The App is quite large and does a mixture of web page serving, API calls and Scheduled Tasks
More and more frequently I am having to reboot the application server as the whole app has ground to a halt, checking DB stats I can see the number of connections has gone through the roof along with database CPU
(big spike as app stops responding, soon as I restart Jboss it drops back)
The database logs show that the connection to the client has been lost:
LOG: could not send data to client: Broken pipe
FATAL: connection to client lost
The jboss logs start filling up as transactions time-out...
Caused by: javax.transaction.RollbackException: ARJUNA016063: The transaction is not active!
The only way to fix is to restart JBoss and the number of connections goes back to normal.
My DB datasource configuration looks like this..
<datasource jta="false" jndi-name="java:/appWebDatasource" pool-name="jdbc/appWebDatasource" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>jdbc:postgresql://${web.db.url}/MyApp</connection-url>
<driver>postgresql</driver>
<security>
<user-name>jboss</user-name>
<password>******</password>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
I have been checking the pg_stat_activity table as soon as the issue occurs and there are no idle in transaction connections, they are all either idle or active
So my question is, how to configure JBoss or Postgresql in a way to stop this increase in number of connections that crashes the app??
You can have a cap on the max number of connections by declaring the max pool size you want to allow with this paramater <max-pool-size>
You have to consider your application and choose an appropriate size to set in <max-pool-size>
As you need to use the validation checker mechanism also along with parameter already mentioned by DaveB in data source configuration, given in the doc.

jboss-eap-5.1 heap out of memory

My system run out of memory sometimes. I can see bellow error in logs every time when system is running out of heap memory
Maximum number of threads (200) created for connector with address abc.com/192.168.1.45 and port 8080
Any ideas why this is happening?
JBoss is crashing due to a high number of threads created. When it tries to create a new one, the application stops responding and starts to shutdown the application server.
Increasing the maxThreads parameter will resolve the issue. Do this incrementally; raising the value of maxThreads too much can result in performance problems such as:
High memory usage
General slowness due to the JVM being forced to context switch
between many threads frequently
To increase maxThreads edit in JBOSS_EAP_DIST/jboss-as/server/PROFILE/deploy/jbossweb.sar/server.xml
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}"
connectionTimeout="20000" redirectPort="8443" maxThreads="3000"
minSpareThreads="2000" maxKeepAliveRequests="-1" />
see also: Performance Tuning Guide - Chapter 2. Connectors

What is the Max Pool Connection size if no Max Pool Connection is set in -ds.xml?

Does anyone know what the default value is of the max pool size within the -ds.xml file? As you can see below we only have minimum set to 0 with no entry for maxium. I'm worried the vendor who configured this was thinking no maximum entry means unlimited. Im wondering if no entry takes the default value Jboss assigns. I'm not sure what that value is.
Reason i'm concerned is because I'm getting this error:
Njavax.transaction.TransactionRolledbackException: Error obtaining connection: org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ));
My -ds.xml file
datasources>
<local-tx-datasource>
<jndi-name>SabaSite</jndi-name>
<connection-url>saba:jdbc:JSQLConnect://********/database=######/asciiStringParameters=false</connection-url>
<driver-class>com.saba.mssql.SabaJNETMSSQLDatabaseDriver</driver-class>
<min-pool-size>0</min-pool-size>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</local-tx-datasource>
</datasources>
Thanks,
Justin
You can check actual datasource properties yourself with help of JMX Console.
See How to check datasource in JBoss?