Fork me on GitHub
#datomic
<
2021-02-04
>
Jake Shelby02:02:13

I'm seeing some behavior in datomic cloud (both remote connection, and when deployed in ions), that is contrary to what I've been led to believe as "the database as a value". When I acquire a "current" DB value from a connection, their hash is new every time I ask for it, even though the DB values have the same t basis. When I run the same test with dev-local, I do see the desired behavior, that in fact, 2 DBs of the same basis are equal. Does anybody know why the client API behaves this way, and why it's different from dev-local?

;; dev-local connection, using dl/divert-system
  (let [c   (conn)
        db1 (d/db c)
        db2 (d/db c)]
    {:db1      db1
     :db2      db2
     :db1-hash (hash db1)
     :db2-hash (hash db2)
     :eq?      (= db1 db2)
     :type     (type db1)})
  ;; => {:db1
  ;;     #datomic.core.db.Db{:id "import-202123-1720", :basisT 3151, :indexBasisT -1, :index-root-id nil, :asOfT nil, :sinceT nil, :raw nil},
  ;;     :db2
  ;;     #datomic.core.db.Db{:id "import-202123-1720", :basisT 3151, :indexBasisT -1, :index-root-id nil, :asOfT nil, :sinceT nil, :raw nil},
  ;;     :db1-hash -1795899545, ;; These stay the same as long as nothing more is transacted
  ;;     :db2-hash -1795899545, ;; These stay the same as long as nothing more is transacted
  ;;     :eq? true, ;; This was intended
  ;;     :type datomic.core.db.Db}

  ;; Remote connection, using :server-type :ion
  (let [c   (conn "core-prod" "XXXX.core.prod")
        db1 (d/db c)
        db2 (d/db c)]
    {:db1      db1
     :db2      db2
     :db1-hash (hash db1)
     :db2-hash (hash db2)
     :eq?      (= db1 db2)
     :type     (type db1)})
  ;; => {:db1
  ;;     {:t 3150, :next-t 3151, :db-name "XXXX.core.prod", :database-id "de0a365c-eb28-4cf4-a490-bd0bcfff8104", :type :datomic.client/db},
  ;;     :db2
  ;;     {:t 3150, :next-t 3151, :db-name "XXXX.core.prod", :database-id "de0a365c-eb28-4cf4-a490-bd0bcfff8104", :type :datomic.client/db},
  ;;     :db1-hash 256930107, ** New hash values everytime I acquire **
  ;;     :db2-hash 8175244, ** New hash values everytime I acquire **
  ;;     :eq? false, ;; ** This is not intended **
  ;;     :type datomic.client.impl.shared.Db}

tatut05:02:46

It is a value in the sense that passing the same db to a query will give the same results… but not in more strict senses

tatut06:02:23

I wouldn’t rely on the identity or hash of the db handle

Jake Shelby15:02:49

This was one of the biggest benefits that I saw early on: https://youtu.be/4iaIwiemqfo?t=3755

joe smith05:02:53

What is a Query group? If I'm in production, do I also need to launch a Query group server as well? For development, is the Solo instance missing any features from the production Datomic?

danieroux10:02:45

A query group is a separate cluster that reads and caches the data, so it doesn’t affect your other clusters. It becomes useful when you have different workloads on the system

joe smith06:02:50

is it possible to build a REST api around Datomic so that it can be called by other API end points sort of like microservice architectures? I want to have a serverless (AWS Lambda) web facing API for handling application logic and then use datomic to keep track of financial transactions (in particular double entry ledger). I want to be able to do /datomic/ledger/user234/credit/1000 and it should make that changes on the datomic. I guess this is where the lambda proxies come in that can expose datomic functions on AWS API Gateway/Lambda ? With the above scenario, do I lose any performance benefits for reading, (I have a vague understanding of Peer and caching) by calling everything over the wire (rest api)? If so, how should I be architecting here? Lastly, what AWS Database do you recommend for storage? If I use RDS MySQL instance, will I be able to do SQL queries as well? Or is it completely opaque regardless of what underlying DB you use? Thanks again!

tatut07:02:30

You certainly can make a REST API around your Datomic stuff

tatut07:02:50

Datomic cloud doesn’t allow you to specify what storage to use afaict

danieroux10:02:29

It is completely opaque, you cannot specify storage but: https://docs.datomic.com/cloud/analytics/analytics-concepts.html will give you SQL view into the database https://www.youtube.com/watch?v=thpzXjmYyGk is a deep dive on Datomic Ions, worth watching

joe smith01:02:35

thanks guys!

eraad19:02:48

Hi! I would appreciate pointers on how to avoid an IAM user from deleting a database

Schmoho20:02:19

I am super confused by the Datomic product range ... I just want to develop a personal project that needs to run only locally on my machine using Datomic. Now I understand I should either use Datomic Free or Datomic Starter, but now I've also come across dev-local which apparently provides the Client API - does that then not entail any storage? What exactly is dev-local?

Schmoho20:02:13

Ah yeah reading this a little more thoroughly would have answered the storage question ... the "why the diversity" question not really though. 😉 thanks

kenny20:02:46

There's two different products -- Cloud and On-Prem. Datomic free is mostly deprecated, I think.

alexmiller20:02:16

dev-local has storage and is probably a great match for this if it's a personal project

✔️ 3
Schmoho20:02:29

Ok thanks ... why are there three "free to use" versions of Datomic? Is it all about licensing?

alexmiller20:02:58

I would defer to someone on the Datomic team to answer that more fully so that I don't say something dumb :)