From my POV, YugabyteDB is a perfect alternative to CockroachDB for SpiceDB. However, its default behavior conflicts with strict Zanzibar requirements.
I want to build a custom Yugabyte datastore driver (forking the native Postgres driver as a base). Here is my breakdown of the challenges and how I plan to tackle them:
__The Problems__
**Isolation Mismatch**: Yugabyte defaults to Snapshot Isolation. SpiceDB strictly needs global SERIALIZABLE to prevent the New-Enemy Problem.
**Optimistic Concurrency Overdrive**: In Serializable mode, Yugabyte resolves conflicts via Fail-on-Conflict. High SpiceDB write/read contention will cause massive 40001 (Serialization Failure) aborts, destroying throughput.
**Clock Skew Sensitivity**: Without TrueTime hardware, Yugabyte uses HLCs. If node clocks drift, multi-row linearizability risks breaking.
__**The Implementation Ideas**__
**Enforce SERIALIZABLE per connection**: Explicitly enforce it upon session initialization (SET SESSION...) instead of relying on global DB configs.
**Driver-Level Retry Engine**: Intercept 40001 errors and resolve them internally via Exponential Backoff + Jitter to keep worker nodes from smashing into each other.
**Pessimistic Locking via FOR UPDATE NOWAIT**: For high-contention rows (namespace/relation updates), force Yugabyte to fail immediately so the driver's retry engine can back off instantly rather than blocking connections.
**Time-Travel Queries (AS OF SYSTEM TIME)**: Map SpiceDB’s ZedTokens directly to Yugabyte’s historical MVCC reads. Since historical reads don't block writes, this should eliminate a massive chunk of read/write conflicts.
**Hardened Cluster Requirements**: Document that deployment requires aggressive NTP/Chrony sync (clock skew < 5ms) and a hardened --max_clock_skew_usec flag.
__Torture Me / Feedback Requested!__
I'm pretty stubborn, and even though I don't fully grasp every SpiceDB edge case yet, I'm going to see this through. Please hit me with honest feedback!