Running spicedb on top of PSQL w/ some read replicas and for the most part things are amazing - service handles many requests and w/ low latency. However every once in a while there seems to be periodic spikes where latency spikes >= 5s (our max timeout configured). When we had no timeouts we saw in some instances where requests would go > 9 minutes. The latency/spikes always appeared to originate from the same pod, and go routines would appear to build up on that pod. I think there are some previous threads around deadlocks wrt inflight schema that have similar symptoms but not sure if related at all. Reducing the timeout has seemingly helped mitigate the impact of it, but has made getting a pprof more difficult while its happening, and we still do see the occasional 5 second spikes.
During these spikes, there doesnt appear to be any saturation on the psql pool. Minimum or no latency in acquiring the locks. In fact things (logs, cpu, etc) seem to fall off a cliff generally.
I do see instances of this occuring when we are running large reconciliation workflows. In some cases we use spicedb as a cache to have rels available in our larger permission graph, and our synchronization involves generating expected relationships from external source and bringing spicedb up to par with those (deleting, touching rels based on set differentiation). Sometimes this can involve touching a lot of relationships, and some of the larger more legacy workflows can involve reading a lot of relations (long lived relation stream).
It's unclear to me if the two are related. My impression was that large read rels should have minimal impact when compared to say LR, given it's one query and not an unbounded fan out. But wondering if theres any obvious concerns there or if specific metrics/symptoms to look for? Not super familiar w the read in transaction and if that could come into play here.