are bulk operations atomic, and
# spicedb
f
are bulk operations atomic, and secuential? So, if I do a delete all relationships "#member" on a specific resource, then I create a relationship "#member" on that resource, on the same bulk operation, the order matters, and the created one wont be deleted by the filter delete? And, if one fails, none will be performed?
v
With bulk operations you refer to a
WriteRelationships
call?
SpiceDB will return an error if you have the same relationship multiple times as part of the same
WriteRelationships
call, so you can't effectively delete and create.
f
Yes, I mean the writerelationships
I thought I could use that one with filter deletes but I think I can't?
I don't want to delete and create the same one
I want to delete all and create one
Yeah I think that to use the ``WriteRelationships`` call I have to specify all the specific relationships, no filter delete. That's fine, even though filter delete would have been nice here
v
you can't delete all because this can't be done transactionally without creating a massive transaction that will halt your database to a grind. For that you should use
DeleteRelationships
.
it has filters, and it also allows deleting in batches you can throttle on the client side.
I think eventually we'd want to add the
DeleteRelationships
filter to
WriteRealtionships
, but if you are deleting thousands of rels, it's not going to scale, so you'll need to resort to
DeleteRelationships
anyway
f
Yeah, I'm only deleting one relationship, but it's as a way for me to not have to make up a query to the postgres database to see what that relationship is
v
I'm not sure I follow. I believe deletes via
DeleteRelationships
are idempotent, so you don't need to check if it exists
t
https://github.com/authzed/spicedb/issues/2033 I made an issue that I believe asks for the same thing, the ability to atomically “set” the subjects of a relationship without needing to explicitly know/delete the previous values
f
yeah I mean I just dont know the ID, unless I check on the database what that ID is. So deleting every relationship, is a valid option, because that ressource should only have one relationship of that type
yep, this is what I want basically
6 Views