Stupid Q: If I run two operations (
# spicedb
b
Stupid Q: If I run two operations (deletes) in parrallel, I'll get back two zedtokens. How do I know which one was written last aka which one should I use for my next read? Im using the nodejs client FWIW.
v
not a stupid question at all, and some folks have indeed been asking themselves the same: see https://github.com/authzed/spicedb/issues/1162 If I understand your context correctly, there is no causal order to those deletes, they can happen in any random order. One way to address that would be to delete them as part of the same transaction (e.g. using
WriteRelationships
). I infer that you care about the new enemy problem or you need read your own writes consistency. In both cases I think the client should either serialize the operations (run serially) or execute them in the same transaction. Eventually we will be exploring how to enable clients to compare zedtokens, but right now there is no means for it, and we discourage decoding the zedtokens as their implementation may change at any time.
It would help if you could describe your use-case from a business domain perspective
b
Perfect! I have another related question... Would it be faster / more efficient to delete relationships individually with a bulk WriteRelationships OR doing one DeleteRelationshipsRequest with the resouce and object id?
v
They are roughly the same, but serve different purposes. For example if you want to bulk delete thousands of relationships, you should be using
DeleteRelationships
. If you want to write transactionally with deletes, you can only do that with
WriteRelationships
. If you want to delete a single relationship, both should be basically the same.