Skip to main content

One post tagged with "AI agents"

View All Tags

PGAIBench and AAA: can AI safely change production Postgres?

· 18 min read
Nikolay Samokhvalov
CEO & Founder
The AAA architecture for production Postgres, in three tiers. Top: two AI roles with no direct write access to databases. The Analyst investigates, drafts a change request, and rehearses it; the Auditor reviews the change request together with clone telemetry and can send it back, reject it, or approve it. Middle: the Actor, a deterministic runner and the sole write path to databases. Bottom: a two-node Clones cluster (primary and standby) and an illustrative fortified three-node Production Postgres HA cluster (one primary and two standbys), each fitted with a read-only telemetry emitter that safely broadcasts signals for Analyst, Auditor, and Actor to consume. After a change lands in production, a feedback loop returns production outcomes to both Auditor and Analyst so the system improves over time.

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.2 tied 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.7 dropping 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.3 saw a fast green test on a compact table and waved through a dangerous SET NOT NULL lock, while claude-haiku-5.5 overreacted 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. [1] PGAIBench https://pgaibench.dev/