Fork me on GitHub
#datomic
<
2017-06-28
>
yusup03:06:07

Hi, is it possible to rollback Datomic to certain timestamp?

danielstockton10:06:36

@yusup I believe there are two options, using log API to get assertions/retractions since t: 1) Add/retract respectively (keep history of the rollback) b) Excise them http://docs.datomic.com/excision.html (history is gone)

marshall12:06:07

@yusup it depends a little bit on what you mean by ‘rollback’

marshall12:06:34

As @danielstockton said, you can issue a set of compensating transactions

marshall12:06:51

but the basis-t of the resulting database will not be a ‘rollback’

marshall12:06:06

t will continue to increase in either scenario. Unless you have a backup of the db at the specific t you want there isn’t a way to revert the entirety of a db (including t values)

marshall12:06:28

unless you’re just wanting to ‘revert’ for reading (i.e. “show me what the database looked like yesterday”)

marshall12:06:10

if that’s what you’re looking for you can use asOf to get a value of the database exactly as it was at a given time in the past

val_waeselynck13:06:35

@yusup note that you won't be able to use db.with() on the asOf db

hmaurer14:06:07

@val_waeselynck you can’t fork the past?

hmaurer14:06:15

that’s unfortunate; what’s the technical reason for it?

val_waeselynck14:06:51

@hmaurer exactly, I don't know why, already complained about it on http://receptive.io - if it hurts you too, you can upvote the feature request :)

hmaurer14:06:37

@val_waeselynck It doesn’t hurt me right now as I haven’t used Datomic on a project yet, but it sounds like a feature that could be extremely valuable when debugging

hmaurer14:06:50

e.g. go back in time and wonder “what would have happened if those operations were applied instead”

hmaurer14:06:57

it might be an edge-case though…

val_waeselynck14:06:16

I couldn't agree more

val_waeselynck14:06:14

Maybe @marshall can give us a technical reason if there is one?

danielcompton21:06:20

We're really interested in using that kind of feature for post-mortem debugging, to exactly reproduce errors

spieden21:06:39

@danielcompton you could do something similar on a transient basis using datomic.api/with

danielcompton21:06:19

@spieden I can query the db as of that time, but I can't issue transactions on the db as of that time

spieden21:06:15

@danielcompton using d/with i believe you could, in a way. you’d have to pass the dbval returned around to other code for it to see your changes

danielcompton21:06:34

I don't think that's possible at the moment

spieden21:06:52

ah ok, sorry didn’t see that

danielcompton21:06:30

np, we're pretty keen on this kind of feature 🙂

spieden21:06:51

i used d/with for the first time in production code recently. handy for accessing all the data related to an entity you’ll transact later if everything works out

val_waeselynck21:06:46

Indeed, it's not possible. It will not throw an exception, but it will return an incorrect result.

timgilbert22:06:31

Is there a way to see what the result of calling a transactor function would be without actually calling the function? I have a retractEntity that's acting a little squirrelly and I want to check my math

favila22:06:47

(d/invoke the-db :db.fn/retractEntity the-db the-eid)

favila22:06:09

this will return a vector of :db/retracts

favila22:06:32

you can also use d/with, but this is less direct