Fork me on GitHub
#datomic
<
2019-09-11
>
pithyless12:09:29

Does anybody have experience with round-tripping EDN data (nested, up to 10 MB each) from Clojure to Datomic (on-prem)? My first guess would be to store it as :db.type/bytes (vs :db.type/string) and probably encode via nippy (but also considering transit+json, transit+msgpack, or fressian). As far as I know, Datomic internally uses fressian, but I've seen reports online that not all EDN data roundtrips correctly -- anyone know more? Anyone have first-hand experience with this use-case? I'm mainly interested in relative performance of read/write, compressed size in the db, and any gotchas to watch out for.

gordon13:09:56

First-hand experience with Regex literals not round-tripping

favila13:09:52

IME to use fressian well you need to know exactly what types you expect to serialize and set your read and write handlers up carefully

favila13:09:12

out of the box even the clj wrapper will do some surprising roundtrips

favila13:09:23

nippy is definitely an easier out of the box experience

favila13:09:01

(with clojure data)

pithyless14:09:55

Thanks for the comments. nippy has open GH issues related to large memory usage; transit+msgpack has open GH issues related to encoding byte[] as base64 strings. Which makes me wonder if I shouldn't just use transit+json. Maybe someone else will pitch in with thoughts; otherwise I'm left with just running some synthetic benchmarks ;]

favila14:09:59

you really shouldn’t store any blobs in datomic that are large enough to cause nippy memory issues

favila14:09:44

If you’re talking about storing a single 10mb value, that is definitely too big for datomic

favila13:09:51

I semi-frequently get “Unexpected end of ZLIB input stream” during on-prem client api usage. any clues as to why?

favila13:09:25

#error {
 :cause Unexpected end of ZLIB input stream
 :data {:datomic.client-spi/request-id 97ac9bd9-b6cf-4d2b-87fc-d7a1289005d7, :cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.anomalies/message Unexpected end of ZLIB input stream, :dbs [{:database-id datomic:, :t 322871158, :next-t 322871160, :history false}]}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message Unexpected end of ZLIB input stream
   :data {:datomic.client-spi/request-id 97ac9bd9-b6cf-4d2b-87fc-d7a1289005d7, :cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.anomalies/message Unexpected end of ZLIB input stream, :dbs [{:database-id datomic:, :history false}]}
   :at [datomic.client.api.async$ares invokeStatic async.clj 58]}]
 :trace
 [[datomic.client.api.async$ares invokeStatic async.clj 58]
  [datomic.client.api.async$ares invoke async.clj 54]
  [datomic.client.api.sync$unchunk invokeStatic sync.clj 47]
  [datomic.client.api.sync$unchunk invoke sync.clj 45]
  [datomic.client.api.sync$eval12765$fn__12786 invoke sync.clj 101]
  [datomic.client.api.impl$fn__2619$G__2614__2626 invoke impl.clj 33]
  [datomic.client.api$q invokeStatic api.clj 351]

favila14:09:28

(I got a similar exception when using a laptop peer with a janky valcache setup (process-shared valcache, running inside a file mounted as a block device; it would transiently read a valcache file as 0 bytes, rerunning the query would always fix), but this peer server has a Proper valcache setup in the cloud. Related or red herring?)

johnjelinek17:09:33

is anyone using datomic as a replacement for kafka?

the2bears18:09:33

@johnjelinek what's your use case? Seems to me, at least, that Datomic and Kafka are quite different.

johnjelinek18:09:24

event streaming

marshall18:09:45

i’d tend to use datomic with kafka

marshall18:09:10

not sure i’d do ES with datomic alone if it is a high throughput system

marshall18:09:15

i.e. lots and lots of events

johnjelinek18:09:03

I don't have lots of events

johnjelinek18:09:30

I just want to replace SNS/SQS/DynamoDB/RDS/Kinesis with datomic

marshall19:09:52

you certainly could. you need to keep in mind that your event source will need to have logic for retrying transactions in case of failure

marshall19:09:04

which is something that queues and/or things like kafka can often help with

favila19:09:43

I have used datomic on-prem’s tx-report-queue to provide an event source for other systems (i.e. they take some action reacting to a transaction). But this is definitely cutting some corners. datom updates are very granular, so you need some tx discipline (e.g. tx metadata describing the “semantic” meaning of the tx) to know what happened and decide what should be done

favila19:09:11

You can use datomic to have the ease-of-use of a normal db system where the source of truth is the graph of data at rest (vs an event-source system where the events are primary and you need to devise a projection), while using the tx-queue for some of the niceties of an event-source model for other projections or for creating commands

favila19:09:36

but if you have actual commands (i.e., perform this side effect against an external system) you are much better off using a proper command event in a proper queue that provides retries, dead-letter, etc for you. You can still have something in the middle to read the tx queue and create commands on another queue

favila19:09:25

signs you are doing it wrong: transactions whose purpose is purely to trigger an email or http request; job entities which stores the progress of a job and also drive its execution via db writes; you need to replay portions of the tx queue to get side-effects to retrigger

johnjelinek20:09:07

@U09R86PA4: oh -- so, instead of doing it wrong, I should use kafka?

favila20:09:22

put it this way: you will likely burn yourself if you try to make datomic’s tx queue drive command execution

favila20:09:30

those are signs you might be trying to do that

favila20:09:44

in those cases I think you should use a real queue and datomic is not a good replacement

favila20:09:49

but if you just want some event-sourcing niceties via the tx-queue without the event-sourcing complexity of using a queue, well defined events, defining an indexed projection, etc, you can replace e.g. kafka for your event source in some circumstances

favila20:09:42

the event vs command distinction was not something I really grasped until I did it wrong a few times (using datomic’s tx-queue it so happens)

johnjelinek20:09:53

hmm ... well, I'm pretty new to all of it, and was hoping to simplify my infrastructure as I explore the paradigm (opposed to synchronous systems and shared state through distributed RESTful services)

johnjelinek20:09:08

any advice/tutorials/resources is greatly appreciated

leongrapenthin19:09:24

Can I allocate stateful resources in Datomic Cloud? E. g. if I want to have a cache that I use in an ION, how would I size it?

marshall19:09:31

@leongrapenthin for something that you don’t want to store in the db?

leongrapenthin19:09:45

yes, for example to cache calculations

leongrapenthin19:09:32

or external API calls

leongrapenthin19:09:54

assume sth. like a zip to geolocation resolver

leongrapenthin19:09:27

would probably be a good fit to cache in db, i know - but my question is generally how much memory is available

marshall19:09:13

i would tend to avoid that approach if possible. ions run in the same JVM as your datomic database system, so anything you use there is competing with datomic itself

marshall19:09:26

with the exception that you could probably get away with it in a query group

marshall19:09:55

however, i would still tend toward using an AWS service separately for this (i.e. put it in s3 or on EFS or store it in parameter store, etc)

iku00088819:09:54

Am I correct to understand that this is only available in cloud? http://blog.datomic.com/2019/06/return-maps-for-datomic-cloud-clients.html Would be so great if it is available in on-prem 😭

favila19:09:59

It is available for on-prem:

(d/q '[:find ?e :keys :e :where [(ground 1) ?e]] )
=> [{:e 1}]

marshall19:09:26

absolutely available in on-prem

iku00088800:09:24

I get 'Argument :keys in :find is not a variable' with something like this

(d/q '[:find ?c :keys :c :where [?c :customer/id "id"]])

iku00088800:09:12

@U05120CBV @U09R86PA4 Thanks for taking a look 😄 Glad that it is not a cloud only thing!

favila00:09:30

Your datomic client/peer version is not new enough

iku00088800:09:24

😮 That could be it

iku00088800:09:28

com.datomic/client-pro {:mvn/version "0.8.28"}

iku00088800:09:55

Hah, latest is 0.9.37