Hi everyone! How's it going?
# spicedb
t
Hi everyone! How's it going? I have a question about read consistency: If I write a relation to spicedb and try to read it immediately after, is there a chance I might get nothing? I'm using the default consistency option (which I guess is the minimize_latency) I have this scenario in which I write relatioships and, right after, another service tries to check a permission. However, it sometimes gets a falsy response from the check (even though all writes happened successfully)
y
there's a strong likelihood that you'll get nothing
if you want to be able to read your writes, you should be using
at_least_as_fresh
with the zedtoken that came back from the write
fully_consistent
is a potential alternative, but we generally recommend against using it when it's avoidable
t
Thanks for the quick response!
I don't think we will be able to forward the zed token in my usecase. The api would become a little awkward. What are the tradeoffs of using fully_consistent in this case?
And at what point does a relation becomes visible to a reader using minimize_latency? I'm considering just retrying a few more times in case it returns false
y
fully_consistent
completely removes SpiceDB's cache from the equation, which means that it won't scale
under default configuration, it's about 5s, which is the quantization window
fwiw, at my old company, we spent a long time trying to figure out how to abstract over the notion of zedtokens and ultimately decided that ignoring them or working around them was more painful than using them
even though carrying them through the application was somewhat awkward
t
Interesting! How do you usually design your APIs? For example, if I have a POST /document, how would the response look like? e.g.:
Copy code
{
  id: document_123,
  name: foobar
  description: lorem ipsum
  zed_token: <token>
}
y
yeah, more or less. the zedtoken gets stored on the application's datastore row and returned with the object.
maybe call it
revision
if you don't want to leak the nomenclature?
t
Thanks! Will take a look
6 Views