Hi all! Long time developer, first time Clojurist/XTDB-ian.
I’ve been playing with XTDB 2.x (with an eye towards production) and ran into an issue. It appears that storing a record with a value that’s a hash-map with string keys doesn’t work. As an example:
(xt/submit-tx my-node [[:put :event {:xt/id "msg_8675309"
:name "sent_message"
:data {"to" "+15551234567"
"segements" 1}}]])
The XTDB server (running through Docker) reports:
java.lang.IllegalArgumentException: No matching clause: :map
at xtdb.types$eval4486$fn__4487.invoke(types.clj:143)
at clojure.lang.MultiFn.invoke(MultiFn.java:239)
at xtdb.types$col_type__GT_field.invokeStatic(types.clj:173)
at xtdb.types$col_type__GT_field.invoke(types.clj:171)
at xtdb.vector.writer$eval6088$fn$reify$reify__6117.apply(writer.clj:769)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
at xtdb.vector.writer$eval6088$fn$reify__6110.writerForType(writer.clj:754)
at xtdb.vector.writer$eval6052$fn__6055.invoke(writer.clj:589)
at xtdb.vector.writer$eval5599$fn__5611$G__5590__5618.invoke(writer.clj:34)
at xtdb.tx_producer$__GT_put_writer$write_put_BANG___24838.invoke(tx_producer.clj:283)
at xtdb.tx_producer$write_tx_ops_BANG_.invokeStatic(tx_producer.clj:360)
at xtdb.tx_producer$write_tx_ops_BANG_.invoke(tx_producer.clj:347)
at xtdb.tx_producer$serialize_tx_ops.invokeStatic(tx_producer.clj:381)
at xtdb.tx_producer$serialize_tx_ops.invoke(tx_producer.clj:367)
at xtdb.tx_producer.TxProducer.submitTx(tx_producer.clj:403)
at xtdb.node.Node.submit_tx_AMPERSAND_(node.clj:103)
at xtdb.server$eval35039$fn__35040$fn__35042.invoke(server.clj:65)
at sieppari.interceptor$eval34217$fn__34218$fn__34219.invoke(interceptor.cljc:33)
at sieppari.core$_try.invokeStatic(core.cljc:20)
at sieppari.core$_try.invoke(core.cljc:17)
at sieppari.core$enter.invokeStatic(core.cljc:62)
at sieppari.core$enter.invoke(core.cljc:49)
at sieppari.core$execute$fn__34423.invoke(core.cljc:125)
at sieppari.core$execute.invokeStatic(core.cljc:123)
at sieppari.core$execute.invoke(core.cljc:117)
at reitit.interceptor.sieppari$reify__34432.execute(sieppari.clj:18)
at reitit.http$ring_handler$fn__33494.invoke(http.cljc:165)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.AFunction$1.doInvoke(AFunction.java:31)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at ring.adapter.jetty9$proxy_async_handler$fn__34962.invoke(jetty9.clj:70)
at ring.adapter.jetty9.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:51)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
at org.eclipse.jetty.server.Server.handle(Server.java:562)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:406)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:663)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:398)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:138)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:378)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
at java.base/java.lang.Thread.run(Thread.java:833)
If I switch the keys to keywords, inserting a record works:
(xt/submit-tx my-node [[:put :event {:xt/id "msg_8675309"
:name "sent_message"
:data {:to "+15551234567"
:segements 1}}]])
The Docker invocation for the XTDB server is:
docker run -p 5432:5432 -p 3001:3000 ghcr.io/xtdb/xtdb-ea@sha256:32ad41db657406269177a3e02562a3157083cd4bdef15ca9ee5c82ae77931356
Some background color: I’m looking to store (parsed) JSON objects and want to keep the keys as their original strings.
Are string keys in a hash-map not supported, or was I lucky enough to find a bug?
Thanks!