<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Datomic Knowledgebase - Recent questions tagged bug</title>
<link>https://ask.datomic.com/index.php/tag/bug</link>
<description>Powered by Question2Answer</description>
<item>
<title>datomic&#039;s spymemcached fork collides with original</title>
<link>https://ask.datomic.com/index.php/1075/datomics-spymemcached-fork-collides-with-original</link>
<description>&lt;p&gt;Datomic seems to be shading spymemcached. The logger implementation of spymemcached uses the property &lt;code&gt;net.spy.log.LoggerImpl&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately that property wasn&#039;t shaded properly in datomic - the fork uses the naked property without a prefix. This means setting that property crashes either datomic startup or spymemcached startup, because the same class cannot be used in both places.&lt;/p&gt;
</description>
<category>Peer API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/1075/datomics-spymemcached-fork-collides-with-original</guid>
<pubDate>Mon, 24 Feb 2025 19:02:52 +0000</pubDate>
</item>
<item>
<title>Regression in latest datomic when transacting data &amp; schema in one tx</title>
<link>https://ask.datomic.com/index.php/1070/regression-latest-datomic-when-transacting-data-schema-one</link>
<description>&lt;p&gt;Let&#039;s say you have a transaction like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:db/id :admin/id,
 :db/unique :db.unique/identity
 :db.install/_attribute :db.part/db}
{:db/id &quot;admin&quot;
  :db/ident :admin/bug
  :admin/id admin-id}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(So both schema &amp;amp; data in one tx)&lt;/p&gt;
&lt;p&gt;Normally you would expect idents to work properly - e.g. after that transaction &lt;code&gt;(d/entity db [:admin/id admin-id])&lt;/code&gt; would return the &lt;code&gt;:admin/bug&lt;/code&gt; entity. Unfortunately that&#039;s not the case (though it used to work in previous versions of datomic) - it returns nil. Splitting the transaction into two makes everything work.&lt;/p&gt;
&lt;p&gt;Here&#039;s a full repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require &#039;[datomic.api :as d])
(def conn (d/connect (doto (str &quot;datomic:mem://&quot; (d/squuid)) (d/create-database))))
@(d/transact conn [{:db/id &quot;new&quot;
                    :db/ident :admin/id,
                    :db/valueType :db.type/uuid,
                    :db/cardinality :db.cardinality/one,
                    :db/doc &quot;Id of the admin&quot;
                    :db.install/_attribute :db.part/db}])

(def admin-id (d/squuid))

@(d/transact conn [{:db/id :admin/id,
                    :db/unique :db.unique/identity
                    :db.install/_attribute :db.part/db}
                   {:db/id &quot;admin&quot;
                    :db/ident :admin/bug
                    :admin/id admin-id}])

(def db (d/db conn))

(if (some? (d/entity db [:admin/id admin-id]))
  (println &quot;All OK - admin is found by identity&quot;)
  (println &quot;Admin identity not there? Let&#039;s see the entity: &quot; (d/touch (d/entity db :admin/bug))))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/1070/regression-latest-datomic-when-transacting-data-schema-one</guid>
<pubDate>Wed, 19 Feb 2025 20:44:39 +0000</pubDate>
</item>
<item>
<title>import-cloud not compatible with :db.type/uri</title>
<link>https://ask.datomic.com/index.php/870/import-cloud-not-compatible-with-db-type-uri</link>
<description>&lt;h2&gt;Environment&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/dev-local    {:mvn/version &quot;1.0.243&quot;}&lt;/li&gt;
&lt;li&gt;com.datomic/client-cloud {:mvn/version &quot;1.0.122&quot;}&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;History&lt;/h2&gt;
&lt;p&gt;First setup a new DB in a &lt;strong&gt;cloud&lt;/strong&gt; system. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def db-name &quot;kwill-test3&quot;)
(d/create-database client {:db-name db-name})
(def conn (d/connect client {:db-name db-name}))
(d/transact conn {:tx-data [{:db/ident       :uri/full-uri
                             :db/valueType   :db.type/uri
                             :db/cardinality :db.cardinality/one}]})
(d/transact conn {:tx-data [{:uri/full-uri (java.net.URI. &quot;https://h.readthedocs.io/en/latest/api-reference/&quot;)}]})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Attempt to run &lt;code&gt;dl/import-cloud&lt;/code&gt;. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(dl/import-cloud
  {:source (assoc client-argm :db-name db-name)
   :dest   {:system      &quot;uri-test&quot;
            :server-type :dev-local
            :db-name     db-name}})
Execution error (IllegalArgumentException) at org.fressian.handlers.WriteHandlerLookup/requireWriteHandler (WriteHandlerLookup.java:48).
Cannot write https://h.readthedocs.io/en/latest/api-reference/ as tag null
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Expectation&lt;/h2&gt;
&lt;p&gt;Running import-cloud for any and all of the supported Datomic value types will import data to the dev-local system. &lt;/p&gt;
&lt;h2&gt;Actual&lt;/h2&gt;
&lt;p&gt;Running import-cloud on a cloud database that contains a URI fails with an &lt;code&gt;IllegalArgumentException&lt;/code&gt;. &lt;/p&gt;
&lt;h2&gt;Evidence&lt;/h2&gt;
&lt;p&gt;The example written in &quot;History&quot; is always reproducible.&lt;/p&gt;
&lt;h2&gt;Impact&lt;/h2&gt;
&lt;p&gt;System that have a value for a attribute with the type &lt;code&gt;:db.type/uri&lt;/code&gt; cannot be imported with import-cloud. &lt;/p&gt;
</description>
<category>dev-tools</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/870/import-cloud-not-compatible-with-db-type-uri</guid>
<pubDate>Tue, 14 Feb 2023 21:09:22 +0000</pubDate>
</item>
<item>
<title>d/with crashes when called rapidly in dev-local</title>
<link>https://ask.datomic.com/index.php/866/d-with-crashes-when-called-rapidly-in-dev-local</link>
<description>&lt;p&gt;&lt;code&gt;com.datomic/dev-local {:mvn/version &quot;1.0.243&quot;}&lt;/code&gt;&lt;br&gt;
&lt;code&gt;datomic.client.api&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;One of our dataflow experiments is thrashing d/with rapidly (for each keystroke in a form connected by websocket) and it crashes. Obviously this is not a reasonable circumstance but wanted to report as a possible concurrency bug.&lt;/p&gt;
&lt;p&gt;I&#039;m not able to repro minimally yet. Confounding variables include concurrency model, whether the d/with calls are parallel or composed, whether the d/with calls are interrupting each other or concurrent, how Datomic responds to ThreadInterruptedException, and likely more.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;d/with, tx: ([:db/add 536561674378709 :label/name &quot;6&quot;]) ...success

d/with, tx: ([:db/add 536561674378709 :label/name &quot;65&quot;]) ...failure, e:  
#error {
 :cause nil
 :via
 [{:type java.nio.channels.ClosedChannelException
   :message nil
   :at [sun.nio.ch.FileChannelImpl ensureOpen FileChannelImpl.java 159]}]
 :trace
 [[sun.nio.ch.FileChannelImpl ensureOpen FileChannelImpl.java 159]
  [sun.nio.ch.FileChannelImpl read FileChannelImpl.java 814]
  [datomic.dev_local.io$read_n_bbuf invokeStatic io.clj 66]
  [datomic.dev_local.io$read_n_bbuf invoke io.clj 63]
  [datomic.dev_local.io$read_n_buf invokeStatic io.clj 72]
  [datomic.dev_local.io$read_n_buf invoke io.clj 69]
  [datomic.dev_local.tx$keyoff_datom_bbuf invokeStatic tx.clj 374]
  [datomic.dev_local.tx$keyoff_datom_bbuf invokePrim tx.clj -1]
  [datomic.dev_local.tx$datom_lookup_valfn invokeStatic tx.clj 401]
  [datomic.dev_local.tx$datom_lookup_valfn invoke tx.clj 397]
  [datomic.dev_local.local_log.LocalLog valAt local_log.clj 56]
  [datomic.dev_local.btindex_db$double_lookup$reify__19853 valAt btindex_db.clj 404]
  [datomic.dev_local.btindex$lookup_cmp$reify__19649 valAt btindex.clj 268]
  [datomic.dev_local.btindex.BTIndexLeaf leftk btindex.clj 238]
  [datomic.dev_local.btindex$leftk invokeStatic btindex.clj 59]
  [datomic.dev_local.btindex$leftk invoke btindex.clj 58]
  [datomic.dev_local.btindex.BTIndexBranch bspos btindex.clj 165]
  [datomic.dev_local.btindex.BTIndexBranch seek btindex.clj 184]
  [datomic.dev_local.btindex.BTIndexBranch seek btindex.clj 185]
  [datomic.dev_local.btindex.BTIndex seek btindex.clj 310]
  [datomic.core.btset$seek invokeStatic btset.clj 405]
  [datomic.core.btset$seek invoke btset.clj 400]
  [datomic.core.db.Db seekEAVT db.clj 2195]
  [datomic.core.db$find_eavt invokeStatic db.clj 1135]
  [datomic.core.db$find_eavt invoke db.clj 1129]
  [datomic.core.db$find_eavt invokeStatic db.clj 1132]
  [datomic.core.db$find_eavt invoke db.clj 1129]
  [datomic.core.db$next_valid_inst invokeStatic db.clj 3041]
  [datomic.core.db$next_valid_inst invoke db.clj 3037]
  [datomic.core.db.ProcessExpander getData db.clj 3291]
  [datomic.dev_local.btindex_db$expand_tx invokeStatic btindex_db.clj 445]
  [datomic.dev_local.btindex_db$expand_tx invoke btindex_db.clj 429]
  [datomic.dev_local.with_db.WithDb with with_db.clj 73]
  [datomic.client.api$with invokeStatic api.clj 363]
  [datomic.client.api$with invoke api.clj 353]
  [clojure.core$eval39795$fn__39796$fn__39797 invoke NO_SOURCE_FILE 0]
  [clojure.core$eval39787$fn__39788$fn__39789$fn__39790 invoke NO_SOURCE_FILE 0]
  [clojure.lang.Atom swap Atom.java 37]
  [clojure.core$swap_BANG_ invokeStatic core.clj 2369]
  [clojure.core$swap_BANG_ invoke core.clj 2362]
  [clojure.core$eval39787$fn__39788$fn__39789 invoke NO_SOURCE_FILE 0]
  [hyperfiddle.photon$wrap_STAR_$cr31022_block_0__31024$cr31022_place_2__31025 invoke photon.cljc 154]
  [missionary.impl.Thunk run Thunk.java 58]
  [java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1136]
  [java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 635]
  [java.lang.Thread run Thread.java 833]]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;some test code that does NOT repro the bug:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  (def tx1 [[:db/add 536561674378709 :label/name &quot;6&quot;]])
  (def tx2 [[:db/add 536561674378709 :label/name &quot;65&quot;]])
  
  (def db0 (d/with-db test/datomic-conn)) ; mbrainz-samples
  
  (do
    (:db-after (d/with db0 {:tx-data tx1}))
    (:db-after (d/with db0 {:tx-data tx2})))

  (let [db1 (:db-after (d/with db0 {:tx-data tx1}))
        db2 (:db-after (d/with db1 {:tx-data tx2}))]
    db2)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/866/d-with-crashes-when-called-rapidly-in-dev-local</guid>
<pubDate>Mon, 19 Dec 2022 18:11:18 +0000</pubDate>
</item>
<item>
<title>equality on d/entity ignores db</title>
<link>https://ask.datomic.com/index.php/859/equality-on-d-entity-ignores-db</link>
<description>&lt;p&gt;Expected: entity object equality semantics to consider their database value in determining equality, such that entities derived from differing database values are not equal&lt;/p&gt;
&lt;p&gt;Observed: entities derived from inconsistent database values are considered equal.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def edward 694891374557546)
(def db2 (:db-after (d/with test/datomic-db [[:db/add edward :google/display-name &quot;a&quot;]])))
(= (d/entity test/datomic-db edward) (d/entity db2 edward)) ; true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why we care: when using Datomic entity API with a reactive dataflow engine, the reactive engine uses &lt;code&gt;= &lt;/code&gt; to detect dirty expressions to schedule reevaluation, and here, two very different entity values are considered equal causing the reactive engine to incorrectly cache the expression without reevaluating (i.e. reuse a buffered prior instance of the entity that is inconsistent with the latest db).&lt;/p&gt;
&lt;p&gt;also see &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/tonsky/datascript/issues/433&quot;&gt;https://github.com/tonsky/datascript/issues/433&lt;/a&gt; – Datascript had the same bug. &lt;/p&gt;
&lt;p&gt;Impl note: false negatives are not an issue (i.e. in the case of two equal database values that are not identical references, returning a false negative here may be acceptable, resulting in imperfect caching but no visibly broken behavior in user apps)&lt;/p&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/859/equality-on-d-entity-ignores-db</guid>
<pubDate>Sun, 20 Nov 2022 20:49:46 +0000</pubDate>
</item>
<item>
<title>Duplicate var in :find and :with throws ArrayIndexOutOfBoundsException</title>
<link>https://ask.datomic.com/index.php/724/duplicate-find-with-throws-arrayindexoutofboundsexception</link>
<description>&lt;h2&gt;&lt;strong&gt;Environment&lt;/strong&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/client-cloud &quot;1.0.119&quot;&lt;/li&gt;
&lt;li&gt;com.datomic/dev-local 1.0.242&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;strong&gt;History&lt;/strong&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;(def client (d/client {:server-type :dev-local
                         :storage-dir :mem
                         :system      &quot;test&quot;}))
=&amp;gt; #&#039;user/client
(d/create-database client {:db-name &quot;a&quot;})
=&amp;gt; true
(def conn (d/connect client {:db-name &quot;a&quot;}))
=&amp;gt; #&#039;user/conn
(d/q &#039;[:find ?e
         :where
         [?e :db/ident :db/cardinality]
         :with ?e]
    (d/db conn))
Execution error (ArrayIndexOutOfBoundsException) at datomic.core.datalog/fn$project (datalog.clj:560).
Index 1 out of bounds for length 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you remove the duplicate binding from &lt;code&gt;:with&lt;/code&gt;, the exception will not be thrown. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/q &#039;[:find ?e
         :where [?e :db/ident :db/cardinality]]
    (d/db conn))
=&amp;gt; [[41]]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;strong&gt;Expectation&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;A duplicate var in &lt;code&gt;:find&lt;/code&gt; and &lt;code&gt;:with&lt;/code&gt; returns the same result as no duplicate. &lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Actual&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;A duplicate var in &lt;code&gt;:find&lt;/code&gt; and &lt;code&gt;:with&lt;/code&gt;  throws an &lt;code&gt;ArrayIndexOutOfBoundsException&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Evidence&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Full stacktrace: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#error{:cause &quot;Index 1 out of bounds for length 1&quot;,
       :via [{:type clojure.lang.ExceptionInfo,
              :message &quot;processing clause: [?e :db/ident :db/cardinality], message: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1&quot;,
              :data #:cognitect.anomalies{:category :cognitect.anomalies/incorrect,
                                          :message &quot;processing clause: [?e :db/ident :db/cardinality], message: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1&quot;},
              :at [datomic.core.datalog$throw_query_ex_BANG_ invokeStatic &quot;datalog.clj&quot; 50]}
             {:type java.lang.ArrayIndexOutOfBoundsException,
              :message &quot;Index 1 out of bounds for length 1&quot;,
              :at [clojure.lang.RT aset &quot;RT.java&quot; 2381]}],
       :trace [[clojure.lang.RT aset &quot;RT.java&quot; 2381]
               [datomic.core.datalog$fn__24749$project__24832 invoke &quot;datalog.clj&quot; 560]
               [datomic.core.datalog$fn__24749$join__24850 invoke &quot;datalog.clj&quot; 659]
               [datomic.core.datalog$fn__24749$fn__24853 invoke &quot;datalog.clj&quot; 666]
               [datomic.core.common$pooled_mapv$fn__24505$fn__24506 invoke &quot;common.clj&quot; 490]
               [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
               [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]
               [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]
               [clojure.core$with_bindings_STAR_ invokeStatic &quot;core.clj&quot; 1990]
               [clojure.core$with_bindings_STAR_ doInvoke &quot;core.clj&quot; 1990]
               [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 425]
               [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 156]
               [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 132]
               [clojure.core$apply invokeStatic &quot;core.clj&quot; 671]
               [clojure.core$bound_fn_STAR_$fn__5818 doInvoke &quot;core.clj&quot; 2020]
               [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 397]
               [clojure.lang.AFn call &quot;AFn.java&quot; 18]
               [java.util.concurrent.FutureTask run &quot;FutureTask.java&quot; 264]
               [java.util.concurrent.ThreadPoolExecutor runWorker &quot;ThreadPoolExecutor.java&quot; 1128]
               [java.util.concurrent.ThreadPoolExecutor$Worker run &quot;ThreadPoolExecutor.java&quot; 628]
               [java.lang.Thread run &quot;Thread.java&quot; 829]]}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;strong&gt;Impact&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Programmatically built queries that always add a &lt;code&gt;:with&lt;/code&gt; clause need to detect and remove duplicates prior to issuing the query. This results in extra code and unknown edge cases surfacing.  &lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/724/duplicate-find-with-throws-arrayindexoutofboundsexception</guid>
<pubDate>Tue, 28 Jun 2022 17:39:48 +0000</pubDate>
</item>
<item>
<title>Transactor timeout on transaction function throw</title>
<link>https://ask.datomic.com/index.php/718/transactor-timeout-on-transaction-function-throw</link>
<description>&lt;h3&gt;Version&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/datomic-pro &quot;1.0.6242&quot;&lt;/li&gt;
&lt;li&gt;transactor process 0.9.6045&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;Given the following transaction function definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/transact
 *conn*
 [{:db/ident :demo-throw-fn
   :db/fn (d/function
           {:lang &quot;clojure&quot;
            :params &#039;[db]
            :code &#039;(throw (ex-info &quot;demo&quot; {:type (type #{:one})}))})}])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Execute the transaction function in two environments:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A local environment&lt;/li&gt;
&lt;li&gt;An environment where the transactor runs in a separate process&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Expectation&lt;/h3&gt;
&lt;p&gt;Regardless of the environment, transaction function runtime errors are thrown.&lt;/p&gt;
&lt;h3&gt;Actual&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;In a local environment, execution of the demo function indeed throws an error - in line with expectations.&lt;/li&gt;
&lt;li&gt;In an environment where the transactor runs in a separate process, the transactor times out.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Additional Notes&lt;/h3&gt;
&lt;p&gt;The &lt;em&gt;hypothesis&lt;/em&gt; for the timeout is a second error occurs due to the&lt;br&gt;
&lt;code&gt;(type #{:one})&lt;/code&gt; expression&#039;s result not being serializable. Unfortunately, the timeout error does not reveal what was likely known at some point during execution.&lt;/p&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/718/transactor-timeout-on-transaction-function-throw</guid>
<pubDate>Fri, 27 May 2022 17:54:06 +0000</pubDate>
</item>
<item>
<title>Inconsistent return value using set?</title>
<link>https://ask.datomic.com/index.php/717/inconsistent-return-value-using-set</link>
<description>&lt;h3&gt;Version&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/datomic-pro &quot;1.0.6242&quot;&lt;/li&gt;
&lt;li&gt;transactor process 0.9.6045&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;Given the following transaction function definition.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/transact
 *conn*
 [{:db/ident :demo-fn
   :db/fn (d/function
           {:lang &quot;clojure&quot;
            :params &#039;[db]
            :code &#039;(set? #{:one})})}])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Execute the transaction function in two environments:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A local environment&lt;/li&gt;
&lt;li&gt;An environment where the transactor runs in a separate process&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Expectation&lt;/h3&gt;
&lt;p&gt;Regardless of the environment, the return value of &lt;code&gt;set?&lt;/code&gt; is consistent.&lt;/p&gt;
&lt;h3&gt;Actual&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;In a local environment, the function returns &lt;code&gt;true&lt;/code&gt; - as expected.&lt;/li&gt;
&lt;li&gt;In an environment where the transactor runs in a separate process, the function returns &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Additional Notes&lt;/h3&gt;
&lt;p&gt;The data type of a set is different in the two environments,&lt;br&gt;
&lt;code&gt;clojure.lang.PersistentHashSet&lt;/code&gt; in local and &lt;code&gt;java.util.HashSet&lt;/code&gt; in the other.&lt;/p&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/717/inconsistent-return-value-using-set</guid>
<pubDate>Fri, 27 May 2022 17:51:40 +0000</pubDate>
</item>
<item>
<title>ClassCastException, d/with  inside transact function</title>
<link>https://ask.datomic.com/index.php/638/classcastexception-d-with-inside-transact-function</link>
<description>&lt;p&gt;Calling a transaction function that uses d/with in a dev-local, filesystem (i.e., not :storage-dir :mem) throws a ClassCastException on internal Datomic code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Environment&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/dev-local {:mvn/version &quot;0.9.232&quot;}&lt;/li&gt;
&lt;li&gt;client-cloud 0.8.105&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;History&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Example with exception using file system dev-local.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client (d/client {:server-type :dev-local
                         :storage-dir &quot;/tmp/cce-bug3&quot;
                         :system      &quot;test&quot;}))
=&amp;gt; #&#039;user/client
(d/create-database client {:db-name &quot;test&quot;})
=&amp;gt; true
(def conn (d/connect client {:db-name &quot;test&quot;}))
=&amp;gt; #&#039;user/conn
(d/transact conn {:tx-data [{:db/ident       :user/name
                               :db/valueType   :db.type/string
                               :db/cardinality :db.cardinality/one}]})
=&amp;gt;
{:db-before #datomic.core.db.Db{:id &quot;test&quot;,
                                :basisT 5,
                                :indexBasisT 0,
                                :index-root-id nil,
                                :asOfT nil,
                                :sinceT nil,
                                :raw nil},
 :db-after #datomic.core.db.Db{:id &quot;test&quot;,
                               :basisT 6,
                               :indexBasisT 0,
                               :index-root-id nil,
                               :asOfT nil,
                               :sinceT nil,
                               :raw nil},
 :tx-data [#datom[13194139533318 50 #inst&quot;2021-05-09T00:49:46.400-00:00&quot; 13194139533318 true]
           #datom[73 10 :user/name 13194139533318 true]
           #datom[73 40 23 13194139533318 true]
           #datom[73 41 35 13194139533318 true]
           #datom[0 13 73 13194139533318 true]],
 :tempids {}}
(defn my-tx-fn
    [db argm]
    (let [tx-report (d/with db {:tx-data [{:user/name &quot;asd&quot;}]})]
      []))
=&amp;gt; #&#039;user/my-tx-fn
(d/transact conn {:tx-data [(list &#039;user/my-tx-fn {})]})
Execution error (ClassCastException) at datomic.dev-local.tx/datom-lookup-valfn (tx.clj:397).
class datomic.core.db.Datum cannot be cast to class java.lang.Number (datomic.core.db.Datum is in unnamed module of loader &#039;app&#039;; java.lang.Number is in module java.base of loader &#039;bootstrap&#039;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Working memdb example.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client-memdb (d/client {:server-type :dev-local
                               :storage-dir :mem
                               :system      &quot;test&quot;}))
=&amp;gt; #&#039;user/client-memdb
(d/create-database client-memdb {:db-name &quot;test&quot;})
=&amp;gt; true
(def conn-memdb (d/connect client-memdb {:db-name &quot;test&quot;}))
=&amp;gt; #&#039;user/conn-memdb
(d/transact conn-memdb {:tx-data [{:db/ident       :user/name
                                     :db/valueType   :db.type/string
                                     :db/cardinality :db.cardinality/one}]})
=&amp;gt;
{:db-before #datomic.core.db.Db{:id &quot;394c7a65-bfeb-4dd4-b188-7aecd2057692&quot;,
                                :basisT 5,
                                :indexBasisT 0,
                                :index-root-id nil,
                                :asOfT nil,
                                :sinceT nil,
                                :raw nil},
 :db-after #datomic.core.db.Db{:id &quot;394c7a65-bfeb-4dd4-b188-7aecd2057692&quot;,
                               :basisT 6,
                               :indexBasisT 0,
                               :index-root-id nil,
                               :asOfT nil,
                               :sinceT nil,
                               :raw nil},
 :tx-data [#datom[13194139533318 50 #inst&quot;2021-05-09T01:02:57.965-00:00&quot; 13194139533318 true]
           #datom[73 10 :user/name 13194139533318 true]
           #datom[73 40 23 13194139533318 true]
           #datom[73 41 35 13194139533318 true]
           #datom[0 13 73 13194139533318 true]],
 :tempids {}}
(d/transact conn-memdb {:tx-data [(list &#039;user/my-tx-fn {})]})
=&amp;gt;
{:db-before #datomic.core.db.Db{:id &quot;394c7a65-bfeb-4dd4-b188-7aecd2057692&quot;,
                                :basisT 6,
                                :indexBasisT 0,
                                :index-root-id nil,
                                :asOfT nil,
                                :sinceT nil,
                                :raw nil},
 :db-after #datomic.core.db.Db{:id &quot;394c7a65-bfeb-4dd4-b188-7aecd2057692&quot;,
                               :basisT 7,
                               :indexBasisT 0,
                               :index-root-id nil,
                               :asOfT nil,
                               :sinceT nil,
                               :raw nil},
 :tx-data [#datom[13194139533319 50 #inst&quot;2021-05-09T01:03:08.042-00:00&quot; 13194139533319 true]],
 :tempids {}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Expectation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Transaction functions that use d/with do not throw a ClassCastException. Additionally, the behavior of d/with in all Datomic environments (Cloud, File system, Memdb) is consistent. Given a &lt;a rel=&quot;nofollow&quot; href=&quot;https://forum.datomic.com/t/datomic-cloud-589-8846/1328&quot;&gt;previous Datomic Cloud release&lt;/a&gt; fixed a problem with using with-db from an Ion, it seems using d/with in a transaction function is a supported behavior.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Actual&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The final d/transact transaction function throws a ClassCastException when using d/with on some internal Datomic code. This only occurs when using a dev-local, file system environment.&lt;/p&gt;
&lt;p&gt;Full stacktrace is pasted below.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#error{:cause &quot;class datomic.core.db.Datum cannot be cast to class java.lang.Number (datomic.core.db.Datum is in unnamed module of loader &#039;app&#039;; java.lang.Number is in module java.base of loader &#039;bootstrap&#039;)&quot;,
       :via [{:type java.lang.ClassCastException,
              :message &quot;class datomic.core.db.Datum cannot be cast to class java.lang.Number (datomic.core.db.Datum is in unnamed module of loader &#039;app&#039;; java.lang.Number is in module java.base of loader &#039;bootstrap&#039;)&quot;,
              :at [datomic.dev_local.tx$datom_lookup_valfn invokeStatic &quot;tx.clj&quot; 397]}],
       :trace [[datomic.dev_local.tx$datom_lookup_valfn invokeStatic &quot;tx.clj&quot; 397]
               [datomic.dev_local.tx$datom_lookup_valfn invoke &quot;tx.clj&quot; 397]
               [datomic.dev_local.local_log.LocalLog valAt &quot;local_log.clj&quot; 56]
               [clojure.lang.RT get &quot;RT.java&quot; 760]
               [datomic.dev_local.btindex.BTIndex cons &quot;btindex.clj&quot; 281]
               [clojure.lang.RT conj &quot;RT.java&quot; 677]
               [clojure.core$conj__5390 invokeStatic &quot;core.clj&quot; 85]
               [clojure.core$conj__5390 invoke &quot;core.clj&quot; 82]
               [datomic.core.db.Db addData &quot;db.clj&quot; 2322]
               [datomic.core.db$add_ensured_data invokeStatic &quot;db.clj&quot; 3353]
               [datomic.core.db$add_ensured_data invoke &quot;db.clj&quot; 3351]
               [datomic.core.db$with_tx invokeStatic &quot;db.clj&quot; 3370]
               [datomic.core.db$with_tx invoke &quot;db.clj&quot; 3357]
               [datomic.core.db.Db with &quot;db.clj&quot; 2164]
               [datomic.core.local_db$fn__25633 invokeStatic &quot;local_db.clj&quot; 67]
               [datomic.core.local_db$fn__25633 invoke &quot;local_db.clj&quot; 24]
               [datomic.client.api.protocols$fn__11959$G__11877__11966 invoke &quot;protocols.clj&quot; 126]
               [datomic.client.api$with invokeStatic &quot;api.clj&quot; 363]
               [datomic.client.api$with invoke &quot;api.clj&quot; 353]
               [user$my_tx_fn invokeStatic &quot;user.clj&quot; 3]
               [user$my_tx_fn invoke &quot;user.clj&quot; 20]
               [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 156]
               [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]
               [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
               [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]
               [clojure.core$apply invoke &quot;core.clj&quot; 660]
               [datomic.core.db.ProcessExpander inject &quot;db.clj&quot; 3229]
               [datomic.core.db.ProcessInpoint inject &quot;db.clj&quot; 2950]
               [datomic.dev_local.btindex_db$expand_tx$inject_all__18586$fn__18587 invoke &quot;btindex_db.clj&quot; 440]
               [clojure.lang.PersistentVector reduce &quot;PersistentVector.java&quot; 343]
               [clojure.core$reduce invokeStatic &quot;core.clj&quot; 6827]
               [clojure.core$reduce invoke &quot;core.clj&quot; 6810]
               [datomic.dev_local.btindex_db$expand_tx$inject_all__18586 invoke &quot;btindex_db.clj&quot; 440]
               [datomic.dev_local.btindex_db$expand_tx invokeStatic &quot;btindex_db.clj&quot; 444]
               [datomic.dev_local.btindex_db$expand_tx invoke &quot;btindex_db.clj&quot; 429]
               [datomic.dev_local.btindex_db$with_tx invokeStatic &quot;btindex_db.clj&quot; 468]
               [datomic.dev_local.btindex_db$with_tx invoke &quot;btindex_db.clj&quot; 461]
               [datomic.dev_local.impl.DurableConnection transact &quot;impl.clj&quot; 161]
               [datomic.client.api$transact invokeStatic &quot;api.clj&quot; 200]
               [datomic.client.api$transact invoke &quot;api.clj&quot; 183]
               [user$eval124260 invokeStatic &quot;user.clj&quot; 25]
               [user$eval124260 invoke &quot;user.clj&quot; 25]
               [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7177]
               [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7132]
               [clojure.core$eval invokeStatic &quot;core.clj&quot; 3214]
               [clojure.core$eval invoke &quot;core.clj&quot; 3210]
               [nrepl.middleware.interruptible_eval$evaluate$fn__959 invoke &quot;interruptible_eval.clj&quot; 91]
               [clojure.main$repl$read_eval_print__9086$fn__9089 invoke &quot;main.clj&quot; 437]
               [clojure.main$repl$read_eval_print__9086 invoke &quot;main.clj&quot; 437]
               [clojure.main$repl$fn__9095 invoke &quot;main.clj&quot; 458]
               [clojure.main$repl invokeStatic &quot;main.clj&quot; 458]
               [clojure.main$repl doInvoke &quot;main.clj&quot; 368]
               [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 1523]
               [nrepl.middleware.interruptible_eval$evaluate invokeStatic &quot;interruptible_eval.clj&quot; 84]
               [nrepl.middleware.interruptible_eval$evaluate invoke &quot;interruptible_eval.clj&quot; 56]
               [nrepl.middleware.interruptible_eval$interruptible_eval$fn__985$fn__989
                invoke
                &quot;interruptible_eval.clj&quot;
                155]
               [clojure.lang.AFn run &quot;AFn.java&quot; 22]
               [nrepl.middleware.session$session_exec$main_loop__1086$fn__1090 invoke &quot;session.clj&quot; 190]
               [nrepl.middleware.session$session_exec$main_loop__1086 invoke &quot;session.clj&quot; 189]
               [clojure.lang.AFn run &quot;AFn.java&quot; 22]
               [java.lang.Thread run &quot;Thread.java&quot; 829]]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Evidence&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The previously pasted example is reproducible and always throws a ClassCastException.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Impact&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We are unable to test functionality in a consistent manner. Local setups using dev-local file systems will not function as expected. Developers are unable to test features in the same way they will work in production.&lt;/p&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/638/classcastexception-d-with-inside-transact-function</guid>
<pubDate>Thu, 24 Jun 2021 14:57:51 +0000</pubDate>
</item>
<item>
<title>d/client external server communication</title>
<link>https://ask.datomic.com/index.php/637/d-client-external-server-communication</link>
<description>&lt;p&gt;&lt;strong&gt;Environment&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;com.datomic/client-cloud 0.8.105&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;History&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Get the docstring for &lt;code&gt;d/client&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clojure.repl/doc d/client)
-------------------------
datomic.client.api/client
([arg-map])
  Create a client for a Datomic system. This function does not
communicate with a server and returns immediately.

For a cloud system, arg-map requires:

  :server-type   - :cloud
  :region        - AWS region, e.g. &quot;us-east-1&quot;
  :system        - your system name
  :endpoint      - IP address of your system or query group

Optionally, a cloud system arg-map accepts:

  :creds-provider  - instance of com.amazonaws.auth.AWSCredentialsProvider. Defaults to DefaultAWSCredentialsProviderChain
  :creds-profile   - name of an AWS Named Profile. See http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html
  :proxy-port      - local port for SSH tunnel to bastion 

  Note: :creds-provider and :creds-profile are mutually exclusive, providing both will result in an error.

For a dev-local system, arg-map comprises:

  :server-type   - :dev-local (required)
  :system        - a system name (required)
  :storage-dir   - optional, overrides :storage-dir in ~/.datomic/dev-local.edn

dev-local stores databases under ${storage-dir}/${system}/${db-name}.

For a peer-server system, arg-map requires:

  :server-type   - :peer-server
  :access-key    - access-key from peer server launch
  :secret        - secret from peer server launch
  :endpoint      - peer server host:port
  :validate-hostnames  - false

Returns a client object.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note the second sentence in the docstring: &quot;This function does not communicate with a server and returns immediately.&quot; Next call &lt;code&gt;d/client&lt;/code&gt; with an endpoint that does not exist.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/client {:server-type :ion
             :system      &quot;my-system&quot;
             :endpoint    &quot;http://i-dont-exist.datomic.net:8182&quot;
             :region      &quot;us-west-2&quot;})
Execution error (ExceptionInfo) at datomic.client.impl.cloud/get-s3-auth-path (cloud.clj:179).
Unable to connect to http://i-dont-exist.datomic.net:8182
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Expectation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Calling &lt;code&gt;d/client&lt;/code&gt; does not communicate with a server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Actual&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Calling &lt;code&gt;d/client&lt;/code&gt; does communicate with a server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Evidence&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The above reproducible example indicates the &lt;code&gt;d/client&lt;/code&gt; function call is attempted to communicate the the passing in &lt;code&gt;:endpoint&lt;/code&gt; string given the exception thrown.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Impact&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;d/client&lt;/code&gt; docstring misleads the user by saying no server communication will occur when it does occur. The result is calls to &lt;code&gt;d/client&lt;/code&gt; can fail in unexpected ways when an external server communication is not accounted for. For example, we spin up Datomic Cloud query groups dynamically and attempt to communicate with the newly spun up cluster. Until the cluster is up and healthy, we expect calls to fail at &lt;code&gt;d/connect&lt;/code&gt; with an unavailable anomaly, and instead the calls would fail at &lt;code&gt;d/client&lt;/code&gt; with an unavailable anomaly.&lt;/p&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/637/d-client-external-server-communication</guid>
<pubDate>Thu, 24 Jun 2021 14:55:59 +0000</pubDate>
</item>
<item>
<title>Dev-local query does not support :timeout</title>
<link>https://ask.datomic.com/index.php/564/dev-local-query-does-not-support-timeout</link>
<description>&lt;p&gt;Dev-local 0.9.229 does not appear to support &lt;code&gt;:timeout&lt;/code&gt; when querying. Here is a repro. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client (d/client {:server-type :dev-local
                       :system      &quot;example&quot;}))
(d/create-database client {:db-name &quot;example&quot;})
(def conn (d/connect client {:db-name &quot;example&quot;}))
(d/transact conn {:tx-data [{:db/ident       :string
                             :db/cardinality :db.cardinality/one
                             :db/valueType   :db.type/string}]})
(dotimes [n 1000]
  (d/transact conn {:tx-data (map (fn [i]
                                    {:string (str n i)}) (range 1000))}))
(first
  (d/q {:query   &#039;[:find (pull ?e [*])
                   :where
                   [?e :string]]
        :timeout 1000
        :args    [(d/db conn)]}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The query takes longer than 1s and does not throw. I would have expected an exception thrown. &lt;/p&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/564/dev-local-query-does-not-support-timeout</guid>
<pubDate>Wed, 30 Dec 2020 21:25:39 +0000</pubDate>
</item>
</channel>
</rss>