Camunda and Postgresql throw me an error when debugging on java

Hi all,

when i am in debug mode on java and i stay in the service tasks for some time, i get this error which causes the process to fail :

Error querying database. Cause: org.postgresql.util.PSQLException: This connection has been closed.

The error may exist in org/camunda/bpm/engine/impl/mapping/entity/ProcessDefinition.xml

The error may involve org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity.selectLatestProcessDefinitionByKeyWithoutTenantId

The error occurred while executing a query

SQL: select * from ACT_RE_PROCDEF RES where KEY_ = ? and TENANT_ID_ is null and VERSION_ = ( select max(VERSION_) from ACT_RE_PROCDEF where KEY_ = ? and TENANT_ID_ is null)

Cause: org.postgresql.util.PSQLException: This connection has been closed.

Does anyone know how to fix this?
Thanks

@CamundaUser123 what are your connection pooling settings?

Refer the below settings:

BasicDataSource dbcpDataSource = new BasicDataSource();
dbcpDataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
dbcpDataSource.setUrl(dburl);
dbcpDataSource.setUsername(username);
dbcpDataSource.setPassword(password);    
dbcpDataSource.setInitialSize(10);
dbcpDataSource.setMaxActive(30);
dbcpDataSource.setMinIdle(10);
dbcpDataSource.setMaxIdle(10);
dbcpDataSource.setMaxWait(30000);
dbcpDataSource.setPoolPreparedStatements(true);
//dbcpDataSource.setMaxOpenPreparedStatements(10);
dbcpDataSource.setValidationQuery("select 1");
dbcpDataSource.setValidationQueryTimeout(3);
dbcpDataSource.setTestOnBorrow(true);
dbcpDataSource.setTestWhileIdle(true);
dbcpDataSource.setRemoveAbandoned(true);
dbcpDataSource.setRemoveAbandonedTimeout(300);
dbcpDataSource.setMinEvictableIdleTimeMillis(3600000);
dbcpDataSource.setTimeBetweenEvictionRunsMillis(600000);