Fork me on GitHub
#datahike
<
2024-03-26
>
Fabim08:03:43

I am getting an error (`org.postgresql.util.PSQLException: SSL error: Remote host terminated the handshake` ) when deploying to http://fly.io using postgres. What could I be missing? {:store {:backend :jdbc :dbtype "postgresql" :jdbcUrl "…."}} deps are io.replikativ/datahike-jdbc {:mvn/version "0.3.47"} , org.postgresql/postgresql {:mvn/version "42.7.3"} , com.github.seancorfield/next.jdbc {:mvn/version "1.3.925"} Things where working fine when using in-memory. the build also logs Reflection warning, konserve_jdbc/core.clj:317:3 - reference to field close can't be resolved. is that the issue? Thanks in advance

timo08:03:12

Hey @U010L3S1XHS, that looks like an issue with your postgresql libs. You should probably try to connect to the fly.io-postgresql on the repl. This is not an obvious issue with datahike.

alekcz09:03:24

@U010L3S1XHS sometimes the provider requires SSL and the driver doesn't do so by default. A few years back I had a similar issue with DigitalOcean. Adding ?ssl-mode=REQUIRED to the connection string helped me.

Fabim09:03:22

Thanks for your answer @U8KKDKPG8. I tried ssl-mode required and sslmode=disable as set by http://fly.io but the same error still occurs.

Fabim07:03:54

@U4GEXTNGZ @U8KKDKPG8 do you know a way of using a connection pool like HikariDataSource with datahike-jdbc ? http://fly.io seems to only support sslmode=disabled. adding a connection-pool without ssl might solve the problem, unless I misunderstand where the ssl error comes from.

timo08:03:38

Looking at the error there it seems to use c3p0 as connection pool and in datahike-jdbc it is a dependency: https://github.com/replikativ/konserve-jdbc/blob/main/deps.edn#L8

Fabim08:03:01

@U4GEXTNGZ yes good catch. thanks. konserve-jdbc uses connection/uri->db-spec internally which seems to ignore ?sslmode=disable from the :jdbcUrl. Can’t see how to propagate down this setting to disable ssl

alekcz08:03:14

@U010L3S1XHS lemme look into it. And cut you a new release

Fabim08:03:45

@U8KKDKPG8 amazing, thanks. please let me know what you find. happy to help.

alekcz08:03:06

Do you have a temporary db I could test against?

Fabim08:03:10

I attached the standard postgres in my http://fly.io app during fly launch . Do you mean that?

alekcz08:03:26

Yeah. Could you send me the simplest setup to get that started. I tried yesterday and I didn't see a click to deploy postgres

alekcz08:03:37

Do I have to install their tool?

Fabim08:03:21

yes their cli. then fly auth signup and fly launch and they set you up, then fly deploy. you can then do (System/getenv "DATABASE_URL") to get the :jdbcUrl https://fly.io/docs/hands-on/install-flyctl/

alekcz08:03:46

Cool cool. Give me an hour

👍 1
Fabim09:03:22

If needed I can send you my Dockerfile and build.clj, but no special magic should be needed.

alekcz09:03:41

Could you rather just send me the url to your instance? I went through all the steps but now to deploy I need to give add my cc and pay $5 and it's not pro-rata for my usage

alekcz11:03:55

@U4GEXTNGZ here's the pull request when you're back from holiday: https://github.com/replikativ/konserve-jdbc/pull/21

👍 2
Absolute Negativity10:03:48

Calling db-with (or with) sometimes breaks query on fresh db from @conn, such as:

(d/q
   '[:find [?e ...]
     :where [?e :ts-entity.smith/id]]
   @dev/db-conn)
  ; => [22 28 34 31 23 26 24 33 32 27 30 29 25]

  (dh/db-with @dev/db-conn
              [{:trade/id 
                "ts-entity.smith-bill-detail/128790"}])

  (d/q
   '[:find [?e ...]
     :where [?e :ts-entity.smith/id]]
   @dev/db-conn)
  ; => []
The example is from the system I'm working on; I'm still trying to isolate the problem on a fresh REPL but couldn't produce it so far. If I do release and connect new conn the query would work again. Not all tx-data to db-with breaks it... Trying to see if anyone have any clue and can point me somewhere...

Absolute Negativity14:03:45

These work for some reason...

(d/q
   '[:find [?e ...]
     :where
     [?e ?a]
     [?e :ts-entity.smith/id]]
   @dev/db-conn)
  ;; => [22 28 34 31 23 26 24 33 32 27 30 29 25]  
  (d/q
   '[:find [?e ...]
     :where
     [?e :ts-entity.smith/id]]
   (map seq (d/datoms @dev/db-conn :eavt)))  
  ;; => [22 28 34 31 23 26 24 33 32 27 30 29 25]

timo07:03:31

Hey @U02T2PJHNP4, never seen that problem. Thanks for posting. Maybe someone has an idea...

whilo19:03:35

Thanks for reporting! That is strange and should not happen. Feel free to open an issue @U02T2PJHNP4.

whilo19:03:33

It would be good to be able to reproduce the issue.