PGAIBench and AAA: can AI safely change production Postgres?
Modern engineering teams run far more Postgres clusters than human DBREs can watch by hand, leaving most databases underserved. Our goal is a new operating model where one experienced DBRE or SRE can reliably oversee 1,000 clusters — which requires safe, AI-driven database operations.
Frontier AI models already write valid SQL, and an agent with shell access can run it. The hard part of AI-driven database operations is knowing whether that SQL is safe to run on a live production database.
Ask any experienced database reliability engineer (DBRE) why they will not hand production Postgres to an AI agent, and the answer is rarely syntax. Databases are stateful, and real outages happen when valid SQL collides with different state (often multi-terabyte) and live traffic. A schema change waits for a slow reporting query, and new queries on that table queue behind it; a config change pauses replica recovery; or an index that looks "unused" on the primary powers a critical query on a read replica.
To measure that gap, we built PGAIBench[1] v0.2 and tested frontier models on live two-node Postgres 18.7 clusters under concurrent load. Below, we also propose AAA (Analyst, Auditor, Actor) — a clone-backed separation-of-duties architecture where an Analyst proposes changes without production write access, a deterministic Actor rehearses every step on a live clone and applies only approved steps, and an independent Auditor reviews the clone evidence.
Four key learnings stand out:
- High capability does not prevent live outages. Acting alone,
claude-fable-5.2tied for the top score yet still broke live clusters by restarting nodes against an explicit no-restart rule. - A deterministic clone gate stops mechanical failures at zero LLM cost — yet blind spots remain. Rehearsing on a two-node clone halted broken queries, lock stalls, and replication hangs automatically, while subtler errors — such as
x-ai/grok-4.7dropping indexes that looked unused on the primary and crippling an async read replica — slipped past primary-only checks. - Green clone summaries can both reassure and mislead AI reviewers. Giving Auditors real clone evidence cleared false alarms for most models, yet two failure modes persisted:
z-ai/glm-5.3saw a fast green test on a compact table and waved through a dangerousSET NOT NULLlock, whileclaude-haiku-5.5overreacted to noisy clone telemetry and blocked almost everything. - Separating duties changes the safety curve. In retrospective, in-sample replay of the models' primary changes through AAA, the clone gate and Auditor together would have blocked 12 of 13 measured harms (-92.3%) while approving 377 of 378 safe or unclassified changes (99.7%).
Links
- [1] PGAIBench https://pgaibench.dev/
