theconductor
09/05/2024, 7:24 PMspice.write(relationship1)
spice.write(relationship2)
If the second write fails (perhaps we poorly managed resources and SpiceDB hit an OOM), the first write leaves the DB in an inconsistent state. Yes, I could combine those into one atomic WriteRelationships
, if they were part of the same function or code block. If there's any reason they need to be spread out (which happens pretty often), my code is no longer robust. That's also the case if I mix WriteRelationships
and DeleteRelationships
. Maybe django/postgres has spoiled me, but I think it's hard to see SpiceDB as a true DB without reliable ACID transactions:
with db.transaction():
spice.write(relationship1)
# ... lots of stuff that could fail here ...
spice.write(relationship2)
# transaction commits here