-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: c3p0, PostgreSQL - FATAL: sorry, too many clients already
PostPosted: Sun Sep 10, 2017 6:26 pm 
Newbie

Joined: Mon Jul 03, 2017 6:40 am
Posts: 10
Hi, met strange problem on my Jenkins with Postgre 9.5 running in Docker. Can't reproduce same problem locally using same docker image and same build command.

I run migrations before each testsuite or individual test using Flyway.
All tests run sequentially. There is no concurrent test execution.

Here are my c3p0 settings:
Code:
    properties.put("hibernate.c3p0.min_size", "5")
    properties.put("hibernate.c3p0.max_size", "20")
    properties.put("hibernate.c3p0.timeout", "1800")
    properties.put("hibernate.c3p0.max_statements", "50")


Tests start to fail with exception:
Code:
Unable to obtain Jdbc connection from DataSource (jdbc:postgresql://jenkins-host:34409/postgres) for user 'postgres': FATAL: sorry, too many clients already


I've added some debug stuff to my test suite. Tests failed because max connection limit reached: 100
I've printed out
Code:
select backend_start, xact_start, query_start, waiting, state, query from pg_stat_activity

Code:
2017-09-10 15:08:13.898509│null                      │2017-09-10 15:08:13.966206│false│idle  │SHOW TRANSACTION ISOLATION LEVEL     │
├──────────────────────────┼──────────────────────────┼──────────────────────────┼─────┼──────┼─────────────────────────────────────┤
│2017-09-10 15:08:13.898315│null                      │2017-09-10 15:08:13.966055│false│idle  │SHOW TRANSACTION ISOLATION LEVEL     │



There are ~90 queries "SHOW TRANSACTION ISOLATION LEVEL"
Found some SO post: https://stackoverflow.com/questions/351 ... n-postgres

What should I do next?
Challenge ops with docker/jenkins problem, since problem is not reproducible locally?
Fix config for c3p0?


Top
 Profile  
 
 Post subject: Re: Postgre stops to serve queries. It is c3p0 misconfiguration?
PostPosted: Mon Sep 11, 2017 1:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Most likely, the DB is accessed by other applications. The 100 limit is for the entire database. Even if you set a max size of 20, maybe there are not enough connections available at the DB level. That's also why you can't reproduce it in your local environment.

For example, assume you want to deploy 10 nodes of this application and all could create 20 connections. However, the 100 limit will prevent them to do so.

So, to know what should be the right pool size for all your applications, just use FlexyPool.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.