Help with postgres/datahike FATAL: too many connections for role "u23q0bq15ogiru" after issuing transaction to prod db?
After issuing transaction statement to prod db (Heroku/postgres) the REPL output window returns "incessant" stream of this error message, cannot interrupt (evaluation is already complete) and clogs the output window. Can I ask for suggestions how to stop or suppress?
(By the way, transaction in these cases always succeed; but the return statement -- any other evaluations occurring in interim -- get buried by this connection error log stream.)
hi @feedmyinbox02_clojuri, this is pretty obviously a problem with your postgres-setup/hoster. I don't know exactly how datahike manages connections but this seems to be first and foremost a problem that's not directly on Datahike
you can't even find the words datahike or replikativ in the pastebin
Hmm, ok. I think I remember konserv but could be mistaken. Maybe I will need to check with Alek?
Thanks for chiming in, as always.
@feedmyinbox02_clojuri the konserve instance should only spin up 15 connections
Are there multiple instances of your application? And how many connections is the role permitted?
Konserve can take parameters and pass them to 3cp0. I just need to check if datahike allows for that too
Multiple instances, hmm … I'm embarrassed to say I'm not really sure because I have always “outsourced” that abstraction to Heroku. I somewhat understand Heroku’s concept of dynos.
What tier is you postgres. Essentials has 20 connection max. Two instances and you're over.
Heroku postgres resources, I can see number of connections Basic 1x dyno, I believe
The number of instances would be created by Heroku, am I understanding that right?
c3p0 close()es Connections asynchrously, via its internal thread pool. by default, that pool is small, probably too small for your application. if the thread pool get backlogged, you might have lots of Connections logically closed from c3p0's perspective but physically still open, waiting for the asynchronous close to actually happen. try adding something like
https://stackoverflow.com/questions/43458572/hibernate-c3p0-connection-pool-max-size-is-not-respected
We need to switch to hikari which is a lot more stable than c3p0
The short term solution would be to make your max threads 5 so the overage doesn't go past 20
ok thank you, I can set max threads in the cfg map with datahike, or this is done elsewhere with jdbc or konserv?
Lemme just double check how you actually send it through. It should be on the cfg.
give me 5 min
thanks, of course I am searching datahike docs but I think not documented so will search github codebase
(def cfg {:store {:backend :jdbc
:jdbcUrl ""
:table "samezie2"
:maxPoolSize 5}
:schema-flexibility :read
:keep-history? false}) Any property passed to cfg.store gets passed on to the underlying connection
@feedmyinbox02_clojuri you just need to pass them in the in the camelCase as c3p0 expects. There's no conversion from kebab-case.
Thank you Alek, I appreciate this
You're welcome. I'm happy to help