yogthos / migratus

MIGRATE ALL THE THINGS!
647 stars 95 forks source link

`(proto/connect (proto/store config))` throws 55000 PSQLException "This ResultSet is closed." #140

Closed theronic closed 6 years ago

theronic commented 6 years ago

I'm seeing an opaque PSQLException when I try to migrate a remote Heroku Postgres DB via Migratus. I can query the database manually just fine via JDBC.

How do I get better logging out of Migratus? I've added Slf4j and Timbre, but I can't see any reason why "the ResultSet is closed." Am I missing something?

(def config {:store :database,
 :migration-dir "migrations",
 :migration-table-name "migrations",
 :db "postgresql://abc....eu-west-1.compute.amazonaws.com:5432/....?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"})

;; Test a basic query:
(with-open [conn (jdbc.core/connection (:db config))]
  (jdbc.core/fetch conn "select 1;"))
=> [{:?column? 1}] ;; works fine

;; Now try Migratus:
(require '[migratus.protocols :as proto])
(let [store (proto/make-store config)]
    (try (proto/connect store)
         (catch Exception ex
           (timbre/error ex))))
=>
18-07-12 15:45:32 Petruss-MacBook-Pro.local ERROR [my-project.core.migrations:3] - 
                                                                  clojure.core/eval                          core.clj: 3206
                                                                                ...                                        
                                              my-project.core.migrations/eval46156  boot.user8699304171669809516.clj:    2
                                                 migratus.database.Database/connect                      database.clj:  242
                                                     migratus.database/init-schema!                      database.clj:  191
                                                    migratus.database/table-exists?                      database.clj:  138
                                                  clojure.java.jdbc/db-transaction*                          jdbc.clj:  724
                                                  clojure.java.jdbc/db-transaction*                          jdbc.clj:  732
               org.postgresql.jdbc2.AbstractJdbc2Connection.getTransactionIsolation      AbstractJdbc2Connection.java:  904
                         org.postgresql.jdbc2.AbstractJdbc2Connection.execSQLUpdate      AbstractJdbc2Connection.java:  382
                       org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags       AbstractJdbc2Statement.java:  405
                                org.postgresql.jdbc2.AbstractJdbc2Statement.execute       AbstractJdbc2Statement.java:  561
                                   org.postgresql.core.v3.QueryExecutorImpl.execute            QueryExecutorImpl.java:  255
                            org.postgresql.core.v3.QueryExecutorImpl.processResults            QueryExecutorImpl.java: 1853
org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler.handleResultRows       AbstractJdbc2Statement.java:  221
                                org.postgresql.jdbc4.Jdbc4Statement.createResultSet               Jdbc4Statement.java:   37
                           org.postgresql.jdbc2.AbstractJdbc2ResultSet.setFetchSize       AbstractJdbc2ResultSet.java: 1875
                            org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed       AbstractJdbc2ResultSet.java: 2852
org.postgresql.util.PSQLException: This ResultSet is closed.
     SQLState: "55000"
    errorCode: 0
theronic commented 6 years ago

This misleading error was related to an older Postgres driver that is incompatible with Postgres v10. Resolved by updating deps:

[org.postgresql/postgresql "42.2.3.jre7"] ;; latest driver
;;[postgresql "9.3-1102.jdbc41"] -- old incompatible driver