Fork me on GitHub

Anyone have experience allowing end users to define attributes — and even further — allowing end users to define queries using those attributes?


@conaw: I know that people do such things. You have to consider how much you want to trust your users — Datomic's datalog queries allow arbitrary code execution.


User-defined attributes are pretty safe, as long as the names don't clash.


Also, keep in mind that all idents are kept in memory all the time.


Can you have the user defined attribute stored as an identity — and map it to some generated attribute name — that way the user doesn’t deterimine what the actual query is?


sorry, stored as an entity


Attributes are entities already.


so presumably you could create a new entity when the user is creating some custom relationship, 'user/custom-attr and then generate a unique attribute based on that, which would be the actual entity


I may not have explained that clearly, but the idea is that you limit what queries a user can actually run, and avoid the risk of conflicting attribute names, by having some intermediary entity sitting between what the user thinks the attribute is called and what the actual attribute is that ties an entity to a value


(d/q '[:find (count ?e) :in $ :where ... ] db)) returns nil if there are no entities matching, and not zero. am i misusing count?


@bvulpes: at present, aggregates return nil instead of 0 in cases where there are no matched datoms. We are considering requests around changing this behavior, but for now you'll need to check for nil case manually if you want to return 0. Note this has to do with aggregates in general so you can't e.g. use a workaround with a custom aggregate with that same query.


@bkamphaus: thank you for the clarification!


@bkamphaus: I managed to reproduce the issue mentioned a while ago in this channel: datomic seems to ignore the data-dir setting for indexing jobs when setting it via the property file. I have put together what I think is a minimal example that reproduces it here:


@p.brc: thanks for putting together the repro and report, I’ll look into it.


If I want to store blobs of data as bytes, how big is too big?


Is under 1MB (when serialized as edn) acceptable?


recommended max value size is 1 KB


@stuartsierra: what's the reasoning behind that recommended size? Are there instances where it might be safe to go over? If you can't store blobs bigger than 1kb, any recommended approaches for how to handle it separately?


The way Datomic stores values in its indexes. Index segments in storage are 40-60 KB in size. Large values would bloat the segment sizes.


You can always go over, it's not a hard limit, but performance will degrade with a large quantity of large blob values.


Instead, use a separate blob store and keep just metadata in Datomic.


I see - so even if we don't want any indexes on the blob values, they still can bloat the indexes?


yes, the values still have to be stored. All values are stored in indexes.


even if avet/indexed isn’t turned on, eavt, aevt are covering indexes of segments for all values in Datomic.


I see - thanks for the additional details


Are there any recommendations for ways to store larger blobs that integrate well with datomic holding the metadata? Essentially we just need a key-value DB that's easy to query and join onto datomic data I guess?


@therabidbanana: for maximum ops simplification, use a postgres data store and a field of blobs in there


then you'll have datomic_kvs and therabidbananas_blobs


uuid up and you're done


That's basically what we're thinking of doing, though we had planned on using Cassandra as the datomic datastore (it's what we've used in another project)


Yeah, it can be reasonable to just use the underlying storage, or on aws s3 might be preferred over dynamo. Also if you’re transacting a lot of blob data to the underlying storage it could impact performance, so take the volume you expect to be transacting into consideration.


I had heard that Postgres was not a preferable storage backend for Datomic if we can avoid it - not sure if that's still the case?


@therabidbanana: not preferable for what reasons? The storage choice is really contingent on your familiarity and use case.


@therabidbanana: i asked some cognitect staff about data store selection criteria and the answer was "budget first, then familiarity. if you can swing the price of DDB, use that."


to that end, i use pg as a datastore. granted, the stuff i do is pretty low-throughput, so i've not yet hit performance ceilings or the like, but provisioned reads and writes on ddb get priiiiicey quickly.


plus, mother postgres can do no wrong!


@bkamphaus: heard it from @currentoor, so not sure of the exact details - but apparently someone at Cognitect advised against it since we also had familiarity with Cassandra? Maybe that was because our other use case was more likely to have high amounts of writes though.


Scaling up to high throughput would point to Dynamo, Cassandra, etc. yeah. If you’re familiar with Cassandra then it’s less risky to take on.


yeah I believe we were told cassandra or dynamoDB is preferred because of write scalability, @marshall I believe you mentioned this on the phone


This database, especially without blobs being stored in it, is much less high-throughput on the write side than our other use case though


Yep, given an expectation to scale writes that’s reasonable. Just want to clarify that’s only indicated by scale and not a generic recommendation to avoid Postgres by any means.


Maybe we could swing consolidating in Postgres - we're planning on using it as a store for Quartzite ( already anyway.


hi I’m trying to get a transactor running in a Docker container, linking it to a mysql database that I am running locally. Things seem fine when I docker run my image: in mysql, when I query, I get

mysql> select * from datomic_kvs;
| id | rev | map | val |
| pod-coord |    9 | {:key "[\"\" nil 3306 \"QfiEuYt70Bt3Qy7JVPuuW47I4uLze8+jKUCAcrrXCAI=\" \"uIi+Qhy2RQPs8JHqb6pChvuEWoQTeK0S26hPDrjlcNM=\" 1461711438104 \"0.9.5350\" true 2]"} | NULL |
1 row in set (0.00 sec)
in the repl, I then try to create a database, runing (datomic.api/create-database "datomic:) and i get
HornetQNotConnectedException HQ119007: Cannot connect to server(s). Tried with all available servers.  org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory (
ERROR org.hornetq.core.client - HQ214016: Failed to create netty connection
java.nio.channels.ClosedChannelException: null
	at org.jboss.netty.handler.ssl.SslHandler.channelDisconnected( ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at ~[netty-3.6.7.Final.jar:na]
	at org.jboss.netty.util.internal.DeadLockProofWorker$ ~[netty-3.6.7.Final.jar:na]
	at org.jboss.netty.util.VirtualExecutorService$ ~[netty-3.6.7.Final.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( ~[na:1.8.0_74]
	at java.util.concurrent.ThreadPoolExecutor$ ~[na:1.8.0_74]
	at ~[na:1.8.0_74]
Any ideas on where I am missing something? Also subsidiary question, is the Peer connecting to the transactor or is it the other way around? thanks a lot for any help!


@ambroise: peer connects to transactor


ensure that you have a clear network path to the transactor from wherever the repl is


hi @bvulpes, thanks for your help. I’m actually not sure how the repl (peer) gets the network path to the transactor. Is it supposed to be in the mysql database?


right. because right now, in the mysql db, I have and 3306, which points to the database (and not the docker container)


sounds like you have host=<mysqlhost> in your


gimme a cookie


(i have spent hours automating lately is all)


thanks a lot!


can reverse attribute navigation be used in the :db.cardinality/many situation? something like :foo/_bar [vector-of-lookups-refs], when creating a new foo entity.