Hey folks,
# spicedb
g
Hey folks, We just experienced something off in our spicedb instance. LookupNamespacesWithNames went up like crazy. Our db shows that the following query went up x600 in traffic, where all the rest of the traffic remained the same: SELECT serialized_config, "timestamp" FROM namespace_config AS OF SYSTEM TIME _ WHERE ((namespace = _) OR (namespace = _)) This created a hot replica in our crdb database and a bad latency increase. After a reload of spicedb everything went back to normal. We are using "v1.45.4". We haven't changed the schema recently, nor there was a deployment on spicedb, change of traffic to it. Any clue?
y
are you using
--enable-experimental-watchable-schema-cache
? if you aren't, we highly recommend it, and if you are, i wonder if you somehow hit a degenerate condition around that. the idea is that rather than fetching the schema on every request, it eagerly fetches from the database for a given revision and then holds onto it until it's no longer valid.
g
Thanks @yetitwo, we are indeed not using it. Looking at the docs it says: > While we recommend enabling this, it isn't enabled by default because it requires additional configuration and knowledge of your datastore. For Postgres, track_commit_timestamp must be set to on for the Watch API to be enabled. For Spanner, there are a maximum of 5 changefeeds available globally for a table, and this consumes one of them. There is no mention of cockroachdb, is there anything in particular that we need to do? We do not have premium cockroachdb, in case subscriptions are required
If this requires change feed. Is there an alternative flag that would do the same but polling? Even polling the schema every 30s would be more efficient than what we have now
y
no, cockroachdb is the easy case. there's no additional configuration required.
it also doesn't use enterprise changefeeds - it uses the old-style changefeeds which used to be called experimental changefeeds and i think are just called changefeeds now?
g
Thanks @yetitwo, we've activated the flag. We've also set
kv.rangefeed.enabled
to true in CRDB. We've seen the changefeeds working, but looking at traces LookupNamespacesWithNames is still taking place. Anything we might have missed?
y
you're still going to see it periodically, because it will need to be fetched if the cache doesn't have the revision, but it shouldn't be present in every trace. another question: what consistency value are you using for most of your calls? is it possible that a new user/client is making a bunch of
fully_consistent
calls?
g
Sorry. I'm confused, revision as in zed token or as in revision of the namespace? The schema hasn't changed, shouldn't that be independent of the zed token used? Since that is revision of data. No, most clients use a zed token request. But again. How is fully_consistent have to do with this? Shouldn't fully_consistent relate to the data structure, not to the schema structure?
y
the schema is a part of the data
if you write new schema, it returns a new revision. if you're making
minimize_latency
requests at the time that you write the schema, you're going to continue seeing responses from before you wrote the schema, at least until your quantization interval passes. if you're using
fully_consistent
, SpiceDB needs to read the schema as well as the data to be sure that nothing in the schema has changed.
we've got some upcoming work that will simplify schema storage and reduce the work that SpiceDB has to do here
g
I think that i understand. Is there any way that we can double check that it is really enabled? As I said we haven't seen a reduction in these calls after enabling. Changefeed is running
btw, we had the env variable configured before, but crdb property was not set up, so we thought it was running but it was not the case. We are unsure whether we are in a similar situation
y
hmm. i don't think you would have needed to configure anything on the CRDB side, but i can check that - you may have already had it in place, and the issue you were seeing was unrelated to that environment variable.
g
kv.rangefeed.enabled
was set to false, without that variable changefeeds are not enabled
y
sanity check: have you rolled pods since the crdb changes?
g
yes, we rolled pods
y
hmm. okay, going back to the start. do y'all have tracing implemented? is it associated with a particular request or shape of request?
g
It's hard to know, since I have to go trace by trace, but at least I see it for DeleteRelationships, WriteRelations and CheckPermission
y
ah, so not localized to a particular request?
when it happens, is it an acute/degenerate thing, or is it relatively spread out?
g
except for that incident where the LookupNamespaces spiked. We are generally seeing a continuous volume. I would say spread out.
y
and you said when it spiked that it didn't recover?
what's your CRDB CPU generally at?
g
the problem is that spike of queries for namespaces created a hot replica, since it all comes from a small table, and that hot replica started misbehaving.
y
ah, so general CPU usage isn't a problem
okay, i'm gonna have to think about that
34 Views