Hi team. (0.6.1594) I am having to kill REPL and start up again after changing Wifi network I think. If I try to transact from localhost web app after closing laptop, I get I/O error, reproduced in thread. I think this came up before.
Maybe sqlite closes the connection in this case for some reason. How do you address the sqlite database locally?
I am always just connected to the prod db.
(I am very lazy, what I'm making is very early, no users.)
That is fine.
Since you mention network changes I guess that somehow the connection becomes invalidated with a new IP.
Either by sqlite, or maybe by datahike.
Since you get an I/O error I think it is JDBC/sqlite.
The prod db is postgres on Heroku. JDBC uses sqlite in this instance?
Oh, sorry, you use postgres.
Yes, it's a postgres db
I think it might just be a problem that the underlying JDBC connection breaks during network changes. You will have to reconnect in this case with datahike.
The error could be better handled though. @alekcz360 have you experienced this as well?
Also—maybe this is relevant—I never release the conn after connecting to it in various functions.
Perhaps this is bad practice, I don't really know.
Thanks for the input, whilo!
You don't have to release unless your network connection changes or you don't want to interact with the database anymore. It is fine to hold onto connections in general. JDBC might be more restrictive though, so in this case you have to satisfy JDBC connection management.
I've never had this issue. And we've been using Postgres for a while. I'll look through the stack trace shortly
Is there a previous error or warning before this error?
I don't think so. Usually it happens like this: I am working on my project after jacking-in. After a while, I close my laptop and go to new coffeeshop. I open laptop and try to take an action in my web project from localhost. (Like submit something new to the db.) The web app hangs and then finally gives 500 error with I/O error
To solve the problem, I have to disconnect and close the REPL and start over again.
@feedmyinbox02_clojuri I think this is Postgres. I connected on one WiFi network to postgres, when I change net works and run a command it hangs.
It's been hanging for like 5 min now
could not receive data from server: Operation timed out
SSL SYSCALL error: Operation timed out
The connection to the server was lost. Attempting reset: Succeeded.
psql (17.4, server 16.6 (Debian 16.6-1.pgdg120+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256, compression: off, ALPN: none)I'll look into this when I do the next cut. I want to move away from C3p0 to Hikari
Wow we discovered a new postgres bug?
I think it's too long a timeout
(By we I mean you, lol)
When the time out expired it reconnected easily
it's possible to set timeout in datahike config?
After startup I also repeatedly get this:
; org.postgresql.util.PSQLException: FATAL: too many connections for role "u23q0bq15ogiru"
; SQLState: "53300"
; errorCode: 0
; serverErrorMessage: #object[org.postgresql.util.ServerErrorMessage 0x46ad04f0 "FATAL: too many connections for role \"u23q0bq15ogiru\""]
This repeats maybe 100 or more times before I interrupt. And start over. A lot of these "at startup" errors that happen once a day. Here is fuller pastebin: https://pastebin.com/PyebYStJIn the output REPL (Calva) the error just repeats until I kill the server and start over.
Hmm, this is a new one—just received this for the first time:
HTTP ERROR 500 clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {} {}
URI: /retract-user/i+dont+know+what+the+hell
STATUS: 500
MESSAGE: clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {} {}
SERVLET: -
CAUSED BY: clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {} {}
CAUSED BY: java.util.concurrent.ExecutionException: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: clojure.lang.ExceptionInfo: Connections could not be acquired from the underlying database! {}
CAUSED BY: java.sql.SQLException: Connections could not be acquired from the underlying database!
CAUSED BY: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
CAUSED BY: org.postgresql.util.PSQLException: FATAL: too many connections for role "u23q0bq15ogiru"@feedmyinbox02_clojuri this one usually happens where there aren't enough available connection. The connection pool usually tries to reserve 15 connection. So if they aren't 15 available you'll get this error. It looks like in yours datahike has requested more threads than it should be allow. Are there any REPLs hanging on to the threads. Or maybe the hot reloading is creating multiple instances?
I don't use hot reloading or figwheel. Sometimes I forget to stop a server before terminating an nREPL so perhaps that is causing it.
Server error:
HTTP ERROR 500 clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {} {}
URI: /make-user
STATUS: 500
MESSAGE: clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {} {}
SERVLET: -
CAUSED BY: clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {} {}
CAUSED BY: java.util.concurrent.ExecutionException: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {}
CAUSED BY: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {}
CAUSED BY: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
CAUSED BY: java.net.SocketException: Operation timed outI don't want to vomit the entire stacktrace but here are select snippets relating to datahike:
clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo: An I/O error occurred while sending to the backend. {} {}
at superv.async$throw_if_exception_.invokeStatic(async.cljc:93)
at superv.async$throw_if_exception_.invoke(async.cljc:87)
at datahike.tools$throwable_promise$reify__31338.deref(tools.cljc:85)
at clojure.core$deref.invokeStatic(core.clj:2337)
at clojure.core$deref.invoke(core.clj:2323)
at datahike.api.impl$transact.invokeStatic(impl.cljc:40)
at datahike.api.impl$transact.invoke(impl.cljc:40)
at dental_practice_listing.persistence$create_user.invokeStatic(persistence.clj:91)
at dental_practice_listing.persistence$create_user.invoke(persistence.clj:89)Sure, whilo. Here it is: https://pastebin.com/jn9RyT12
Reconnect to the database? Hmm, I don't touch the code or the REPL in the interim. I am just closing my laptop and when I open next time, I am usually in a new physical location and new network.
Can you post it in a paste bin site maybe?
I suspect this might be a problem with hostnames changing during Wifi swap. Did you reconnect to the database in some way? I need to remove this config check anyway.
Hi alek, just checking in. I continue to receive FATAL: too many connections for role using postgres on Heroku. I am not sure why so many connections. Can I ask you point to resource where I learn more?
Is 15 a sufficient or normal number of connections for production system?
To give some context, from my REPL connected to Heroku db, I ran
(d/transact conn [[:db/add -1 :client "Langston Hughes"]])
In my output.repl this produced 20,000 lines of messages; here is sample: https://pastebin.com/raw/74bkvwkd