Unable to get managed connection for java:jboss/datasources Postgres - Cluster HA - Kubernetes

Hi there,
I have issues with my keycloak(12.0.4) cluster ha connected with PostgreSQL. Every once in a while I’m getting errors like below and then containers restart, because reach out cpu limit…

I tried increase some params in standalone-ha.xml but not solve case.

Params in datasource section - standalone-ha.xml:

Screenshot 2021-10-30 at 22.20.57

Errors:

javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS

Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])

KC-SERVICES0013: Failed authentication: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection

My envs configuration from k8s:

        - name: JGROUPS_DISCOVERY_PROTOCOL                                                                                                                                                                                                                                                                                        
          value: kubernetes.KUBE_PING                                                                                                                                                                                                                                                                                             
        - name: JAVA_OPTS                                                                                                                                                                                                                                                                                                         
          value: >-                                                                                                                                                                                                                                                                                                               
            -XX:+UseContainerSupport                                                                                                                                                                                                                                                                                              
            -XX:MetaspaceSize=96M                                                                                                                                                                                                                                                                                                 
            -Xms1048m -Xmx5000m                                                                                                                                                                                                                                                                                                   
            -XX:MaxMetaspaceSize=512m                                                                                                                                                                                                                                                                                             
            -Djava.net.preferIPv4Stack=true                                                                                                                                                                                                                                                                                       
            -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS                                                                                                                                                                                                                                                                
            -Djava.awt.headless=true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
        - name: CACHE_OWNERS_COUNT                                                                                                                                                                                                                                                                                                
          value: "2"                                                                                                                                                                                                                                                                                                              
        - name: CACHE_OWNERS_AUTH_SESSIONS_COUNT                                                                                                                                                                                                                                                                                  
          value: "2"  

Any ideas?
Thanks in advance for help

1 Like

@jan.domanski we have the same issue. did you ever find a solution for this?