The Simplest Way to Make Gerrit and Spanner Work Like They Should
Teams pair Gerrit and Spanner to review code changes and store review data across global regions. This setup lets developers approve patches in Gerrit while Spanner keeps account and change records in sync. Large engineering groups need fast code reviews and reliable data storage. Gerrit tracks every commit, comment, and approval vote from your team. Spanner provides a distributed relational database that holds this metadata without single points of failure. When you link them, your review serv
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams pair Gerrit and Spanner to review code changes and store review data across global regions. This setup lets developers approve patches in Gerrit while Spanner keeps account and change records in sync.
Large engineering groups need fast code reviews and reliable data storage. Gerrit tracks every commit, comment, and approval vote from your team. Spanner provides a distributed relational database that holds this metadata without single points of failure. When you link them, your review server stays up even if one region goes down.
How Gerrit and Spanner share identity and data
Gerrit needs a valid cloud identity to read and write data inside Spanner. Most teams assign a dedicated service account to the Gerrit server instances. That service account holds an identity role that permits reading and writing database rows. When a developer pushes a commit, Gerrit checks the user identity first. Then Gerrit writes the change metadata and review comments into Spanner tables.
Data flows between the two systems over encrypted cloud network links. Gerrit uses standard database drivers or plugins to send queries to the Spanner API. Spanner processes these transactions and replicates the rows across multiple zones right away. If a second Gerrit node reads the same change, Spanner returns the latest state. This design stops split-brain errors when multiple Gerrit nodes run at the same time.
Common failure modes and how to scope roles
Many teams make the mistake of using one broad service account for everything. If that single account has project-wide admin rights, a bug in Gerrit can harm other databases. Static keys stored on disk also create a big risk for your team. Anyone who copies that key file can read or delete all your review history.
Unlogged queries cause another big problem during security audits and incident reviews. When engineers debug a slow review page, they often run direct queries against Spanner. If they share a team role, the logs do not show who ran which query. Raw query results might also expose personal emails or phone numbers stored in user tables.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these issues by scoping roles down to the single database level. Give the Gerrit service account permission to read and write only its own Spanner tables. Do not grant schema drop rights to the everyday runtime role. Keep schema changes in a separate migration role that only runs during planned upgrades.
Lock down the network path so only known Gerrit nodes can reach the database endpoint. Use workload identity bindings instead of static key files wherever your cloud setup allows it. For human debugging, require every engineer to log in with their own personal identity. Apply data masking rules that rewrite matched emails and phone numbers in query results.
Keeping daily operations fast and safe
Good database hygiene keeps code reviews fast for every developer on the team. Watch your query latency metrics to spot slow joins or missing indexes early. Review your permission grants every quarter to remove old test accounts and unused roles. When you scope permissions well, your code review system stays fast, safe, and easy to audit.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Why do teams run Gerrit with Spanner instead of a local database?
Spanner replicates review metadata across regions so Gerrit stays online during zone outages. A local database on one disk can fail and stop all code reviews.
How should Gerrit log in to Spanner in production?
Bind a dedicated cloud service account to the Gerrit compute host using workload identity. Avoid downloading long-lived static key files to your server disks.
How can we protect user data when engineers query Spanner tables?
Require individual user logins for every database session and turn on query logging. Use data masking to rewrite sensitive fields like emails or phone numbers in results.
Related guides
In this post