<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Datomic Knowledgebase - Recent questions tagged problem</title>
<link>https://ask.datomic.com/index.php/tag/problem</link>
<description>Powered by Question2Answer</description>
<item>
<title>Pulling :db/id will pull the entire entity</title>
<link>https://ask.datomic.com/index.php/703/pulling-db-id-will-pull-the-entire-entity</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 1.0.119&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;p&gt;Reproducible in both dev-local and Cloud client implementations.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require '[datomic.client.api :as d])

(def client (d/client {:server-type :dev-local
                       :system      &quot;test&quot;
                       :storage-dir :mem}))

(d/create-database client {:db-name &quot;bug-example&quot;})

(def conn (d/connect client {:db-name &quot;bug-example&quot;}))

(d/transact conn {:tx-data [{:db/ident       :name
                             :db/valueType   :db.type/string
                             :db/cardinality :db.cardinality/one}]})

(def tx-report
  (d/transact conn {:tx-data [{:db/id &quot;a&quot;
                               :name  &quot;kenny&quot;}]}))

(def db-id (get-in tx-report [:tempids &quot;a&quot;]))

(d/pull (d/db conn)
  [:db/id]
  db-id)
=&amp;gt; {:db/id 83562883711050, :name &quot;kenny&quot;}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;strong&gt;Expectation&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Issuing &lt;code&gt;d/pull&lt;/code&gt; with a selection of &lt;code&gt;[:db/id]&lt;/code&gt; will only pull the &lt;code&gt;:db/id&lt;/code&gt; attribute.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Actual&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Issuing &lt;code&gt;d/pull&lt;/code&gt; with a selection of &lt;code&gt;[:db/id]&lt;/code&gt; will only pull all attributes on the given entity.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Evidence&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;See repro in History.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Impact&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;This bit me when doing some debugging in the REPL. I was trying to just get the db/id of a &quot;top-level&quot; entity, and it pulled the whole thing. This top-level entity is massive and resulted in me needing to restart my REPL. The ability to pull the entirety of an entity is a bit frightening, especially if such a thing were to happen (on purpose or accident) in production. The use of a [*] pull pattern is almost always avoided for this reason. Tracking down a bug like this could be quite tricky since it looks so innocent by appearance.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/703/pulling-db-id-will-pull-the-entire-entity</guid>
<pubDate>Thu, 10 Feb 2022 16:48:24 +0000</pubDate>
</item>
<item>
<title>Long blocking on event `:kv-cluster/get-val` without timeout/retry/failover semantics?</title>
<link>https://ask.datomic.com/index.php/631/blocking-event-cluster-without-timeout-failover-semantics</link>
<description>&lt;p&gt;On a test environment, we're seeing this kind of log from the Datomic Peer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; ~5 hours CI inactive (if this is relevant)

DEBUG 2021-06-18T13:32:37.702 [clojure-agent-send-off-pool-23]: {:event :kv-cluster/get-val, :val-key &quot;60a4cc9e-ac11-40fe-9bd0-582f8209a403&quot;, :phase :begin, :pid 7, :tid 225}

;; 15 minutes pass....

DEBUG 2021-06-18T13:48:25.091 [clojure-agent-send-off-pool-23]: {:event :kv-cluster/get-val, :val-key &quot;60a4cc9e-ac11-40fe-9bd0-582f8209a403&quot;, :msec 947000.0, :phase :end, :pid 7, :tid 225}

;; This next one finishes in 21ms:

DEBUG 2021-06-18T13:48:25.094 [clojure-agent-send-off-pool-23]: {:event :kv-cluster/get-val, :val-key &quot;60128f6d-25fb-41f0-a6c2-9c5e73267da7&quot;, :phase :begin, :pid 7, :tid 225}
DEBUG 2021-06-18T13:48:25.115 [clojure-agent-send-off-pool-23]: {:event :kv-cluster/get-val, :val-key &quot;60128f6d-25fb-41f0-a6c2-9c5e73267da7&quot;, :msec 21.0, :phase :end, :pid 7, :tid 225}

;; and now we start processing the transacts that queued up when the tests started...

INFO  2021-06-18T13:48:25.117 [manifold-execute-43]: {:event :peer/transact, :uuid #uuid &quot;60cca429-7908-49b1-82c8-56b50effb4ce&quot;, :phase :start, :pid 7, :tid 282}
DEBUG 2021-06-18T13:48:25.234 [clojure-agent-send-off-pool-24]: {:event :peer/accept-new, :id #uuid &quot;60cca429-7908-49b1-82c8-56b50effb4ce&quot;, :phase :begin, :pid 7, :tid 226}
DEBUG 2021-06-18T13:48:25.234 [clojure-agent-send-off-pool-24]: {:event :peer/accept-new, :id #uuid &quot;60cca429-7908-49b1-82c8-56b50effb4ce&quot;, :msec 0.462, :phase :end, :pid 7, :tid 226}
INFO  2021-06-18T13:48:25.235 [clojure-agent-send-off-pool-24]: {:event :peer/transact, :uuid #uuid &quot;60cca429-7908-49b1-82c8-56b50effb4ce&quot;, :phase :end, :pid 7, :tid 226}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After those 15 minutes of waiting, the peer moved on and transacted all the transactions that happened to queue in the meantime, as if nothing happened. There do not seem to be any interesting or anomalous logs in the Transactor for this time period.&lt;/p&gt;
&lt;p&gt;Datomic Peer (1.0.6269) with PostgreSQL storage. The peer and transactor are both running on Kubernetes, but Postgres is hosted outside of the k8s cluster.&lt;/p&gt;
&lt;p&gt;I think my followup questions are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Any idea what could be going on with the &lt;code&gt;:kv-cluster/get-val&lt;/code&gt; and how to go about debugging this further?&lt;/li&gt;
&lt;li&gt;Is there some timeout we can configure to avoid this kind of situation in a production environment?&lt;/li&gt;
&lt;li&gt;Is the probable culprit Kubernetes? If so, has someone seen or fixed similar behavior before?&lt;/li&gt;
&lt;li&gt;These logs are happening at the DEBUG level, otherwise we would not even know that the Peer was blocking/hanging/waiting. Are there other metrics or logs we should be monitoring to identify this kind of problem?&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/631/blocking-event-cluster-without-timeout-failover-semantics</guid>
<pubDate>Wed, 23 Jun 2021 09:19:28 +0000</pubDate>
</item>
<item>
<title>Dates coming through incorrectly in Datomic Analytics</title>
<link>https://ask.datomic.com/index.php/620/dates-coming-through-incorrectly-in-datomic-analytics</link>
<description>&lt;p&gt;We are seeing some &lt;code&gt;:db.type/instant&lt;/code&gt; values in Datomic come through as completely different dates in Datomic Analytics.&lt;/p&gt;
&lt;p&gt;For instance&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#inst &quot;2020-01-01T00:00:00.000-00:00&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Shows up in Presto as&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1970-01-19 06:17:16.800
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which suggests that at some point a unix timestamp is being misinterpreted.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(java.util.Date. (/ (.getTime #inst &quot;2020-01-01T00:00:00.000-00:00&quot;) 1000))
;; =&amp;gt; #inst &quot;1970-01-19T06:17:16.800-00:00&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example entity:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (d/q '[:find (pull ?e [*]) :where [?e :accounting.fiscal-year/start-date ?y]] db)
[[{:db/id 17592186045894, :db/ensure [#:db{:id 17592186045471}], :accounting.fiscal-year/start-date #inst &quot;2020-01-01T00:00:00.000-00:00&quot;, :accounting.fiscal-year/end-date #inst &quot;2020-12-31T00:00:00.000-00:00&quot;, :accounting.fiscal-year/closed? false}]]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Field definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (d/q '[:find (pull ?e [* {:db/valueType [:db/ident]}]) :where [?e :db/ident :accounting.fiscal-year/start-date]] db)
[[{:schema/boundary #:db{:id 17592186045443}, :db/unique #:db{:id 38}, :db/valueType #:db{:ident :db.type/instant}, :db.attr/preds [relvn.accounting.dbfn/date-only?], :schema/label &quot;start date&quot;, :db/cardinality #:db{:id 35}, :db/doc &quot;The starting date of a fiscal year.&quot;, :db/id 154, :schema/ident-type #:db{:id 17592186045420}, :db/ident :accounting.fiscal-year/start-date, :db/ensure [#:db{:id 17592186045424}], :schema/entity #:db{:id 17592186045470}}]]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In Presto:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;presto:example_tenant__demo_company_14052021&amp;gt; select * from fiscal_year;
closing_description |       start_date        |        end_date         | closed_ |     db__id     
---------------------+-------------------------+-------------------------+---------+----------------
 NULL                | 1970-01-19 06:17:16.800 | 1970-01-19 15:02:52.800 | false   | 17592186045894 
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Analytics</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/620/dates-coming-through-incorrectly-in-datomic-analytics</guid>
<pubDate>Tue, 01 Jun 2021 04:58:00 +0000</pubDate>
</item>
<item>
<title>Does the transactor eagerly fill memcached with indexed segments?</title>
<link>https://ask.datomic.com/index.php/605/does-transactor-eagerly-fill-memcached-with-indexed-segments</link>
<description>&lt;p&gt;The datomic &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/on-prem/overview/caching.html#memcached&quot;&gt;transactor memcached documentation&lt;/a&gt; says this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;When configured to used memcached, a Datomic process will automatically write into memcached any segment it needs that is not already present in memcached. &lt;strong&gt;In addition, the transactor (only) will write index and log segments to memcached as the segments are produced.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(Emphasis mine.)&lt;/p&gt;
&lt;p&gt;Based on this sentence and assuming a memcached memory pool larger than the storage size that is shared by transactor and peer, my expectation is the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;As the transactor is building an index, it writes newly-created index segments to storage &lt;em&gt;and&lt;/em&gt; to memcached at roughly the same time.&lt;/li&gt;
&lt;li&gt;When the index is finished, it commits the new index root and informs all peers of the new index.&lt;/li&gt;
&lt;li&gt;Any peers using the &lt;em&gt;same&lt;/em&gt; memcached cluster should, at the moment the index is released:&lt;ul&gt;
&lt;li&gt;have a &lt;em&gt;decreasing&lt;/em&gt; ObjectCache hitrate because newly-indexed segments are not cached&lt;/li&gt;
&lt;li&gt;but an &lt;em&gt;increasing&lt;/em&gt; memcached GET count&lt;/li&gt;
&lt;li&gt;and a flat StorageGet and MemcachedPut count because the segments are already in memcached&lt;/li&gt;
&lt;li&gt;For an overall flat or increasing memcached hitrate.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Instead, what I actually see is that when peers accept a new index,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;there's a &lt;em&gt;dramatic&lt;/em&gt; decrease in Memcached hitrate&lt;/li&gt;
&lt;li&gt;and increase in MemcachedPut counts and Storage Get counts.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;IndexWrite&lt;/code&gt; count reported by the transactor is very similar to the MemcachedPut count reported by the peer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This behavior is consistent with the transactor &lt;em&gt;not&lt;/em&gt; writing newly-indexed segments into memcached eagerly while indexing, which is contrary to the documentation.&lt;/p&gt;
&lt;p&gt;So the question: &lt;strong&gt;Does the transactor &lt;em&gt;really&lt;/em&gt; write index segments to memcached as it is indexing?&lt;/strong&gt;&lt;/p&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/605/does-transactor-eagerly-fill-memcached-with-indexed-segments</guid>
<pubDate>Wed, 07 Apr 2021 15:21:18 +0000</pubDate>
</item>
<item>
<title>Why is my float attribute returning double values in queries?</title>
<link>https://ask.datomic.com/index.php/558/why-is-my-float-attribute-returning-double-values-in-queries</link>
<description>&lt;p&gt;I have an attribute of type &lt;code&gt;:db.type/float&lt;/code&gt; in my Datomic Cloud (solo) instance. When I query for that value, however, I get values of type &lt;code&gt;java.lang.Double&lt;/code&gt;. (I actually have 6 float attributes and they all behave this way.)&lt;/p&gt;
&lt;p&gt;Is this a bug? I can't see anything in the documentation that describes this behavior. In fact, the &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/cloud/schema/schema-reference.html#db-valuetype&quot;&gt;schema reference&lt;/a&gt; seems to specifically say that it should be float value and not a double.&lt;/p&gt;
&lt;p&gt;This is not a big problem, but it is an annoyance because the values I'm transacting as floats are getting extra (noisy) precision added to them, so that e.g. when the user enters a 3.7, it actually shows up as 3.700000047683716. This isn't difficult to fix by casting to float, but it was surprising.&lt;/p&gt;
&lt;p&gt;I only see this behavior in Datomic Cloud, by the way. Using dev-local correctly shows the value as a float.&lt;/p&gt;
&lt;p&gt;Here's some relevant exchanges from a REPL session demonstrating the issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (d/q '[:find ?attr-type ?value :where
             [71587003061240196 :student/gpa-weighted-9 ?value]
             [:student/gpa-weighted-9 :db/valueType ?t]
             [?t :db/ident ?attr-type]]
           (d/db conn))
[[:db.type/float 3.700000047683716]]
user&amp;gt; (type (-&amp;gt; *1 first second))
java.lang.Double
user&amp;gt; (float 3.700000047683716)
3.7
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/558/why-is-my-float-attribute-returning-double-values-in-queries</guid>
<pubDate>Thu, 17 Dec 2020 04:25:11 +0000</pubDate>
</item>
</channel>
</rss>