seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
760 stars 90 forks source link

transduce / partition-by / plan can fail with result set closed #149

Closed seancorfield closed 3 years ago

seancorfield commented 3 years ago

Describe the bug Using a stateful transducer with a completing function can throw result set closed exceptions.

To Reproduce TBD

Expected behavior Not sure. Is this an inherent problem with IReduceInit collections that manage their own resources?

Stacktraces n/a

project.clj/deps.edn n/a

Environment (please complete the following information): n/a

Additional context n/a

seancorfield commented 3 years ago

I have a test that reproduces this. I'm trying to decide whether it's really a bug or an inherent problem per Expected behavior above.

seancorfield commented 3 years ago

This is the stacktrace for the exceptions from this case:

    next.jdbc.result_set.MapResultSetBuilder.with_column (result_set.clj:197)
    next.jdbc.result_set$row_builder$fn__3077.invoke (result_set.clj:435)
    clojure.lang.LongRange.reduce (LongRange.java:233)
    clojure.core$reduce.invokeStatic (core.clj:6829)
    clojure.core$reduce.invoke (core.clj:6812)
    next.jdbc.result_set$row_builder.invokeStatic (result_set.clj:435)
    next.jdbc.result_set$row_builder.invoke (result_set.clj:431)
    next.jdbc.result_set$mapify_result_set$reify__3148.seq (result_set.clj:565)
    clojure.lang.APersistentMap$KeySeq.createFromMap (APersistentMap.java:150)
    clojure.lang.RT.keys (RT.java:622)
    clojure.core$keys.invokeStatic (core.clj:1561)
    clojure.core$keys.invoke (core.clj:1557)
    next.jdbc_test$fn__4749$keys_fn__4750.invoke (jdbc_test.clj:825)

This happens in the completing arity of partition-by, which runs after the reduce has handed off the result (and therefore closed the result set).

seancorfield commented 3 years ago

I will update the documentation to add a caveat about this.