The Simplest Way to Make Cloud SQL and Gerrit Work Like They Should
Teams pair cloud sql and gerrit to store code review state in a managed database. Gerrit handles Git reviews while Cloud SQL stores account groups and review metadata. This setup moves account state out of local files and into a shared database. Multiple Gerrit nodes can read the same data and stay in sync during deploys. Your team gets steady code reviews without running a database server by hand. How cloud sql and gerrit share data and logins Gerrit needs a place to store user accounts, re
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 cloud sql and gerrit to store code review state in a managed database. Gerrit handles Git reviews while Cloud SQL stores account groups and review metadata.
This setup moves account state out of local files and into a shared database. Multiple Gerrit nodes can read the same data and stay in sync during deploys. Your team gets steady code reviews without running a database server by hand.
How cloud sql and gerrit share data and logins
Gerrit needs a place to store user accounts, review scores, and project access rules. While Git files hold much of this data, relational databases still back key workflows. Many teams use Cloud SQL for PostgreSQL to hold secondary indexes or external tables.
When a developer pushes a change, Gerrit checks the user identity and project permissions. The Gerrit server opens a database session to Cloud SQL to read or write state. This flow relies on a database user account and a secure network path.
In Cloud SQL for PostgreSQL, customers cannot create users with true superuser attributes. Google reserves full superuser power for its own internal system user. Instead, admins use a custom admin role that grants specific high-level privileges.
That admin role lets you create new roles, databases, event triggers, and extensions. The default postgres user starts with no password and belongs to this admin group. You must set a password for that default user before you can log in.
Gerrit does not need this high-level admin role for daily code review tasks. You should create a dedicated database user just for the Gerrit service. Give that user read and write rights only on the Gerrit schema.
Common failure modes and how to scope roles
The biggest mistake teams make is sharing the default admin user across every service. If Gerrit runs with the main admin account, a bug can harm other databases. Worse, engineers often copy that same shared password into local tools to fix issues.
When three engineers use one shared database login, your audit logs lose all value. You can see a query ran, but you cannot see who ran it. Broad static passwords also stay valid for months and sit in plain text files.
End-to-End Encryption + SQL Query Filtering: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged queries create another big risk during a live site incident. An engineer might log in to Cloud SQL to fix a stuck Gerrit review. Without query logs tied to real names, nobody knows what changed in the tables.
A stray update can expose private emails or phone numbers stored in account tables. Data masking rules can help here by rewriting matched fields like emails in results. That way, support checks do not return raw personal details to the screen.
To fix role creep, split your database accounts by job and person. Give the Gerrit app its own restricted role that can only touch Gerrit tables. Keep the Cloud SQL admin role locked away for schema upgrades only.
Restrict the network path so only Gerrit nodes and approved paths reach Cloud SQL. Turn on database audit logs to track every schema change and manual query. When human engineers need database access, require individual logins instead of a shared secret.
Keeping day two database tasks safe
Even with a clean setup, engineers still need to inspect Gerrit data at times. An admin might check why a merge failed or why a group lookup stalled. These manual checks should never use the same login that the Gerrit server uses.
Set up a separate read-only role in Cloud SQL for routine human checks. If an engineer needs to write data during an outage, require a quick approval. Tie every manual query back to the person who ran it for clear audits.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Does Gerrit need a superuser account on Cloud SQL for PostgreSQL?
No, and Cloud SQL does not let customers use true superuser accounts anyway. Create a standard database user for Gerrit with rights limited to its own database.
How should we handle the default postgres user in Cloud SQL?
The default postgres user starts without a password and holds broad admin rights. Set a strong password right away and do not use it for the Gerrit app.
Why should engineers avoid using the Gerrit service account for manual queries?
Sharing the app account hides who ran a manual query in your logs. Give engineers individual logins and read-only roles so every action has a clear owner.
Related guides
In this post