This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # beginners (95)
- # cider (2)
- # cljdoc (5)
- # cljs-dev (11)
- # cljsrn (2)
- # clojure (12)
- # clojure-spec (11)
- # clojure-uk (3)
- # clojurescript (27)
- # code-reviews (4)
- # cursive (9)
- # data-science (1)
- # datomic (1)
- # emacs (7)
- # fulcro (13)
- # graalvm (28)
- # graphql (6)
- # nrepl (6)
- # off-topic (13)
- # re-frame (3)
- # rewrite-clj (2)
- # shadow-cljs (29)
- # spacemacs (1)
- # sql (4)
- # tools-deps (8)
- # vim (20)
- # yada (7)
Having a problem, any advice/help appreciated!
Using next.jdbc, hikari cp, component...
Just like in the next.jdbc docs, I do
(connection/->pool HikariDataSource db-spec) when I start my db component, let's say this is bound to
In my program/system, I am doing two different kinds of writes to the database:
(sql/insert! c ... the first arg of
insert! takes a
connectable, which AFAICT the result of
(prepare/execute-batch! (jdbc/prepare c [sql-str]) rows-to-insert), which fails because
c is a
connectable, but not a
connection, which is what
prepare needs. My initial fix was to replace
(prepare c with
(prepare (get-connection c), and that works for a very short time, and then I get
HikariPool-1 - Connection is not available, request timed out after 30000ms.
Clearly I am doing something wrong between my use of the result of
->pool, and the connectable/connection that
prepare need, but haven't (yet) figured it out....
OK, more info on the above issue...
My app/system does the
execute-batch! (prepare (get-connection c)... first, then after that returns it does the
I finally figured out how to crank up the hikaricp logs to debug, and it seems that the
execute-batch (prepare (get-connection is taking connections from the pool, and doesn't appear to return them. So after a few calls, all the connections are used up, and subsequent calls timeout waiting for a connection....
So, either I am using connection pool incorrectly EVERYWHERE, or I am using it incorrectly with
A HA! This seems super important and relevant!
It is your responsibility to close the prepared statement after it has been used.