xtdb

Panel 2024-11-05T12:50:46.497689Z

What do I need to setup in v2 + next.jdbc to store a #time/zoned-date-time "2024-05-30T23:57:38.579191Z" ? (sql/insert! db/db :submission_status {:start #time/zoned-date-time "2024-05-30T23:57:38.579191Z"}) 1. Unhandled org.postgresql.util.PSQLException Can't infer the SQL type to use for an instance of java.time.ZonedDateTime. Use setObject() with an explicit Types value to specify the type to use.

jarohen 2024-11-05T13:01:49.367459Z

there's a protocol to implement for this in next.jdbc, whose name I always forget... 👀

jarohen 2024-11-05T13:06:47.530829Z

although I don't recall having to do that for ZDT, I thought either next.jdbc or the PG JDBC driver supported those OotB... 🤔

Panel 2024-11-05T13:12:30.395419Z

I tried requiring [next.jdbc.date-time] that is suppose to do the setup to work with zdt but still having the same issue

Panel 2024-11-05T13:20:44.835569Z

And that's expected since it doesn't cover java.time.ZonedDateTime I think I need to do something like that then:

(extend-protocol rs/ReadableColumn
    java.sql.Date
    (read-column-by-label [^java.sql.Date v _]     (.toLocalDate v))
    (read-column-by-index [^java.sql.Date v _2 _3] (.toLocalDate v))
    java.sql.Timestamp
    (read-column-by-label [^java.sql.Timestamp v _]     (.toLocalDateTime v))
    (read-column-by-index [^java.sql.Timestamp v _2 _3] (.toLocalDateTime v)))

Panel 2024-11-06T06:20:03.917419Z

@seancorfield would you happen to have an example of such setup for next.jdbc ?

Nikolas Pafitis 2024-11-05T22:56:46.076569Z

Any news regarding this https://github.com/xtdb/xtdb-poly-test-hang?

Nikolas Pafitis 2024-11-08T18:11:23.984529Z

@taylor.jeremydavid @jarohen This is the output using clojure 1.12.0

20:10:20.704 [xtdb-tx-subscription-pool-1-thread-1] ERROR xtdb.util -- Uncaught exception:
java.lang.IllegalArgumentException: not all nodes, buffers and variadicBufferCounts were consumed. nodes: [ArrowFieldNode [length=1, nullCount=0], ArrowFieldNode [length=1, nullCount=0], ArrowFieldNode [length=1, nullCount=0], ArrowFieldNode [length=1, nullCount=0], ArrowFieldNode [length=1, nullCount=0], ArrowFieldNode [length=1, nullCount=1], ArrowFieldNode [length=1, nullCount=1], ArrowFieldNode [length=1, nullCount=1], ArrowFieldNode [length=1, nullCount=0]] buffers: [ArrowBuf[48], address:6308528216, capacity:4, ArrowBuf[49], address:6308528224, capacity:1, ArrowBuf[50], address:6308528232, capacity:8, ArrowBuf[51], address:6308528240, capacity:1, ArrowBuf[52], address:6308528248, capacity:1, ArrowBuf[53], address:6308528256, capacity:16, ArrowBuf[54], address:6308528272, capacity:1, ArrowBuf[55], address:6308528280, capacity:8, ArrowBuf[56], address:6308528288, capacity:8, ArrowBuf[57], address:6308528296, capacity:1, ArrowBuf[58], address:6308528304, capacity:8, ArrowBuf[59], address:6308528312, capacity:1, ArrowBuf[60], address:6308528320, capacity:8, ArrowBuf[61], address:6308528328, capacity:1, ArrowBuf[62], address:6308528336, capacity:8, ArrowBuf[63], address:6308528344, capacity:1, ArrowBuf[64], address:6308528352, capacity:8, ArrowBuf[65], address:6308528360, capacity:1] variadicBufferCounts: []
        at org.apache.arrow.vector.VectorLoader.load(VectorLoader.java:98)
        at org.apache.arrow.vector.ipc.ArrowReader.loadRecordBatch(ArrowReader.java:214)
        at org.apache.arrow.vector.ipc.ArrowStreamReader.loadNextBatch(ArrowStreamReader.java:162)
        at xtdb.log.watcher$watch_log_BANG_$reify__27190.accept(watcher.clj:48)
        at xtdb.log$tx_handler$fn__21916.invoke(log.clj:38)
        at clojure.core.protocols$iterator_reduce_BANG_.invokeStatic(protocols.clj:42)
        at clojure.core.protocols$iter_reduce.invokeStatic(protocols.clj:52)
        at clojure.core.protocols$fn__8256.invokeStatic(protocols.clj:74)
        at clojure.core.protocols$fn__8256.invoke(protocols.clj:74)
        at clojure.core.protocols$fn__8203$G__8198__8216.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6965)
        at clojure.core$reduce.invoke(core.clj:6947)
        at xtdb.log.NotifyingSubscriberHandler$fn__21949.invoke(log.clj:97)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Nikolas Pafitis 2024-11-08T18:13:58.217139Z

I guess this is the same issue as before, but instead of hanging, an uncaught exception is thrown?

refset 2024-11-08T18:16:57.098539Z

Interesting, looks to me like a bug in Arrow Java hidethepain

refset 2024-11-08T18:20:25.626039Z

I've opened an issue: https://github.com/xtdb/xtdb/issues/3854

Nikolas Pafitis 2024-11-08T20:34:40.484049Z

@taylor.jeremydavid Does this happen on non macos/apple silicon?

Nikolas Pafitis 2024-11-08T20:50:57.166139Z

Asking since this is different than previous isue (hanging)

seancorfield 2024-11-08T21:07:46.877779Z

I can only confirm that with all the dependencies up-to-date, both of the following commands run to completion as expected, on x64 Ubuntu 20.04 (WSL2):

clojure -M:poly test :dev
clj -M:dev:test -m cognitect.test-runner -d components/persistence-xtdb/test
with Clojure CLI version 1.12.0.1479 and the following deps.edn:
{:mvn/repos {"ossrh-snapshots" {:url ""}}
 :aliases   {:dev  {:extra-paths ["development/src"]

                    :extra-deps  {org.clojure/clojure       {:mvn/version "1.12.0"}
                                  com.xtdb/xtdb-api         {:mvn/version "2.0.0-SNAPSHOT"}
                                  com.xtdb/xtdb-core        {:mvn/version "2.0.0-SNAPSHOT"}
                                  org.clojure/tools.logging {:mvn/version "1.3.0"}
                                  test/xtdb                 {:local/root "components/persistence-xtdb"}}}

             :test {:jvm-opts   ["--add-opens=java.base/java.nio=ALL-UNNAMED"
                                 "-Dio.netty.tryReflectionSetAccessible=true"]
                    :extra-paths ["components/persistence-xtdb/test"]
                    :extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
                                 ch.qos.logback/logback-classic {:mvn/version "1.5.12"}
}
                    :exec-fn cognitect.test-runner.api/test}

             :poly {:jvm-opts   ["--add-opens=java.base/java.nio=ALL-UNNAMED"
                                 "-Dio.netty.tryReflectionSetAccessible=true"]
                    :main-opts  ["-m" "polylith.clj.core.poly-cli.core"]
                    :extra-deps {polylith/clj-poly {:mvn/version "0.2.21"}}}}}

✅ 1
seancorfield 2024-11-08T21:10:01.115659Z

XTDB api 2.0.0-20240910.193517-30 and core 2.0.0-20240910.193517-28

seancorfield 2024-11-08T21:12:12.586609Z

(if I run clj -X:dev:test :dirs '["components/persistence-xtdb/test"]' it runs the tests successfully but then hangs at the end, due to no (shutdown-agents) call and -- I assume -- XTDB having some non-daemon threads active)

👀 1
Nikolas Pafitis 2024-11-08T21:36:39.985799Z

Thanks alot @seancorfield

➕ 1
Nikolas Pafitis 2024-11-05T22:58:50.021419Z

I tried running it but I get a weird error:

Caused by: java.lang.RuntimeException: Unable to find static field: new in class xtdb.types.ClojureForm

refset 2024-11-05T23:06:35.563819Z

ah, that error should be resolvable by upgrading to Clojure 1.12, per https://github.com/xtdb/xtdb/issues/3801#issuecomment-2421779869

refset 2024-11-05T23:08:02.453419Z

I don't know about the repro itself, but is it blocking? or just annoying?

seancorfield 2024-11-05T23:38:44.099269Z

I updated the deps -- Clojure to 1.12 and Poly to 0.2.21 -- and it passes for me on Linux:

clojure -M:poly test :dev
...
Person transacted

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.

Test results: 1 passes, 0 failures, 0 errors.

Execution time: 13 seconds

seancorfield 2024-11-05T23:40:54.296439Z

Does the readme need expanding to make it clearer what the environment and problem is?

seancorfield 2024-11-05T23:42:50.694829Z

Seems to hang when the Cognitect test-runner is used in -X mode -- is that the problem that is "expected" to show up here?

seancorfield 2024-11-05T23:45:08.961459Z

If I run this, it completes successfully:

clj -M:dev:test -m cognitect.test-runner -d components/persistence-xtdb/test
which suggests it is something that shutdown-agents deals with (in the -main case -- it is not called in the -X case).

Nikolas Pafitis 2024-11-06T16:20:52.097559Z

@seancorfield The problem happens on a combination of polylith test, xtdb and macos (apple silicon?)

Nikolas Pafitis 2024-11-06T16:22:04.008319Z

@taylor.jeremydavid Couldn't run any unit tests using XTDB v2. So I'd say kind of blocking. I'll try out tonight with upgrading clojure to 1.12 and report back

🙏 1