datahike

silian 2025-09-03T10:30:32.460619Z

Help with postgres/datahike FATAL: too many connections for role "u23q0bq15ogiru" after issuing transaction to prod db?

silian 2025-09-03T10:35:43.396789Z

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?

silian 2025-09-03T10:38:13.753059Z

(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.)

silian 2025-09-03T10:38:18.365389Z

https://pastebin.com/raw/74bkvwkd

timo 2025-09-03T10:40:25.806069Z

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

timo 2025-09-03T10:41:36.952939Z

you can't even find the words datahike or replikativ in the pastebin

silian 2025-09-03T10:46:09.347509Z

Hmm, ok. I think I remember konserv but could be mistaken. Maybe I will need to check with Alek?

silian 2025-09-03T10:46:29.911509Z

Thanks for chiming in, as always.

👍 1
alekcz 2025-09-03T11:40:15.894849Z

@feedmyinbox02_clojuri the konserve instance should only spin up 15 connections

alekcz 2025-09-03T11:41:33.988449Z

Are there multiple instances of your application? And how many connections is the role permitted?

alekcz 2025-09-03T11:42:46.462119Z

Konserve can take parameters and pass them to 3cp0. I just need to check if datahike allows for that too

silian 2025-09-03T18:24:11.194309Z

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.

alekcz 2025-09-03T18:25:59.457339Z

What tier is you postgres. Essentials has 20 connection max. Two instances and you're over.

silian 2025-09-03T18:28:28.549929Z

Heroku postgres resources, I can see number of connections Basic 1x dyno, I believe

silian 2025-09-03T19:01:57.024869Z

The number of instances would be created by Heroku, am I understanding that right?

alekcz 2025-09-03T19:06:00.324509Z

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

alekcz 2025-09-03T19:06:20.569429Z

We need to switch to hikari which is a lot more stable than c3p0

alekcz 2025-09-03T19:06:56.601089Z

The short term solution would be to make your max threads 5 so the overage doesn't go past 20

silian 2025-09-03T19:12:03.596539Z

ok thank you, I can set max threads in the cfg map with datahike, or this is done elsewhere with jdbc or konserv?

alekcz 2025-09-03T19:13:16.234919Z

Lemme just double check how you actually send it through. It should be on the cfg.

alekcz 2025-09-03T19:13:18.699099Z

give me 5 min

silian 2025-09-03T19:16:31.127649Z

thanks, of course I am searching datahike docs but I think not documented so will search github codebase

alekcz 2025-09-03T19:16:44.850119Z

(def cfg {:store {:backend :jdbc
                   :jdbcUrl ""
                   :table "samezie2"
                   :maxPoolSize 5}
                 :schema-flexibility :read
                 :keep-history? false})

alekcz 2025-09-03T19:17:43.811609Z

Any property passed to cfg.store gets passed on to the underlying connection

alekcz 2025-09-03T19:18:59.590009Z

@feedmyinbox02_clojuri you just need to pass them in the in the camelCase as c3p0 expects. There's no conversion from kebab-case.

silian 2025-09-03T19:39:29.782319Z

Thank you Alek, I appreciate this

alekcz 2025-09-03T19:40:32.337139Z

You're welcome. I'm happy to help

❤️ 1