Fork me on GitHub

just curious; what'd happen if i attempt to restore a backup that's also currently being backed-up-to?

Ben Kamphaus12:09:37

@robert-stuttaford I believe it should work because you can only restore a backup that is in the set of ts which have been fully backed up in that directory, and segments are immutable so nothing will have been changed by backup process (2).


Bump on my question from yesterday, in the hope that there’s someone around now who can help me understand what’s going on:

Ben Kamphaus14:09:09

@eggsyntax I’d write up a gist with a repro case and point it at @marshall or @jaret — as it could be a bug that there’s no error. My estimated reasoning would be that a query like that might work with a reference and since you’re sticking in a Long it might treat it as there not being anything in the reverse index (v/raet).


@marshall or @jaret -- as @bkamphaus suggested above, here's a gist with a minimal complete example of this unexpected behavior in Datomic, where using an underscore as the attribute in a query doesn't return matching datoms. Any insight into what's going on here would be very much appreciated. Thanks!


(Or really @whoever, if anyone else has some clarity about this)


@eggsyntax taking a look now


[EDIT: correct outdated comment]


@eggsyntax: I think it's a consequence of indexes. d/q will not do a full scan of the database, which is essentially what you're asking it to do with [?e _ "whatever"] since ?e is unbound.


With the attribute, the query can use the AEVT index.


But there is no index that starts with V for primitive (non-ref) values.


In most cases where your query would imply a full scan, d/q signals an error, e.g. (d/q '[:find ?e :where [?e _ _]] (d/db conn))


@stuartsierra is correct. if you don’t supply e or a to query, but do supply v, it must be a ref type you’re looking for


but since values of reftypes are just numbers (eids) the query engine doesn’t know if you asked for 42 the entity or 42 the value


@stuartsierra @marshall thanks, y’all, much appreciated. That makes sense. Obviously it’s a terrible idea in most cases, but of idle curiosity, is there a way to actually request a full scan?


nope. any query you try to do it with will throw an exception


you can scan manually with the datoms API


The datoms, index-range, and log APIs are all different ways to "scan" the database. But you can't do it with query.


you're welcome


I do think that throwing an error would be a useful behavior there, btw, to help out other folks who encounter this.


But ultimately, for me, it's a good reminder that I still have leftover SQL intuitions to eradicate 😊


A good way to find all datoms in a given transaction? I've been looking at using d/log, but that requires the conn. This should be doable with just the db, right?


@magnars d/log is best, but I think you can also do something like (d/q '[:find ?e ?a ?v ?tx ?add :in $ ?tx :where [?e ?a ?v ?tx ?add] (d/history db) transaction-eid)