Closed ChrisBlom closed 6 years ago
Can't merge this right now because it may leave some concurrency issues unaddressed. In particular, the proposed change does not let you read your own writes with (datomic.api/db conn)
, and I'm not sure that's okay (stay tuned to this StackOverflow question).
Even if it is okay, the need for a proper implementation of sync
will probably become more necessary.
I'll keep you posted as I make progress.
According to the docs transact
returns a completed future, so that would suggest that
after (d/transact conn data)
finished, the data is transacted, and your writes should be in (d/db conn)
, but it would be good if someone from Datomic can confirm this.
I see now that my implementation is not correct, i've implemened transact-async
not transact
,
i'll fix this. I this the concurrency issue you mean?
I noticed another problem: the future is delivered before the fn that updates the agent returns, so potentially the agent state is not updated yet once the future is delivered, do you now a clean way to solve this?
I noticed another problem: the future is delivered before the fn that updates the agent returns, so potentially the agent state is not updated yet once the future is delivered, do you now a clean way to solve this?
@ChrisBlom it is not another problem, it is the same problem :) I had not noticed the issue with transact
's implementation.
@ChrisBlom thanks, I'd appreciate if you could add a little test for the RYW semantics
And we still need a proper implementation of (d/sync conn t)
, if you want to give it a shot the best strategy I can think of is adding a watch for to the agent that looks up the basis-t (then self-removes)
I've implemented (d/sync conn t)
and added a test for d/transact-async
the implementation is not correct, (d/sync conn t)
does not work when the db already has t, please ignore for now
Uses an agent to manage the state of the mock connection, see https://github.com/vvvvalvalval/datomock/issues/2