Should an agent investigate your production database, or change it?
An agent that looks can save you the first twenty minutes of an incident. An agent that changes things can also make an incident worse, faster. This guide is for database engineers and the teams who decide: what an operations agent may observe, recommend and run, which actions need a person, and how to keep it to five connections so it can never become the load it was sent to fix.
The DBA agent on this site is real, but it is private and has a waitlist. Some parts of this guide describe what it does today. Others are a design you can build. The table says which is which.
| Part | Status | What it means |
|---|---|---|
| Diagnosis | Works today | It matches a symptom to a playbook and runs only that playbook's read-only steps. The session is read-only (default_transaction_read_only = on, a 5 second statement_timeout, a 1 second lock_timeout, application_name = dba-agent). The MongoDB user has only clusterMonitor and readAnyDatabase. A deny list blocks state-changing commands as a second check. You connect it with a read-only user. The scorecard shows the incidents it was tested on. |
| Fixes | Works today | It can propose four fixes: end an idle-in-transaction session, cancel a query, add an index, drop an inactive replication slot. Each is a change request with the command, risk, why, undo, precheck and verify step. A named person approves. On apply it re-checks the precheck and says "stale", running nothing, if the situation changed. It runs on a separate login with only the rights needed, verifies, and writes an audit line. |
| High availability | Works today | python3 -m dbagent.ha manages Patroni, InnoDB Cluster (MySQL Shell), MongoDB replica sets, MySQL Orchestrator and Kubernetes (CloudNativePG; the Percona operators are untested). Reads run freely. Every change shows its command, why, undo and risk, and waits for a typed approval. A read-only check must pass after each change or it stops. Everything goes to a JSONL audit log. High-risk changes (failover or forced promotion, forced quorum, rebuilding a member, forcing a new replica set config, Orchestrator recover) are off by default: it refuses them unless the operator passes --allow-high-risk, and then each still needs the target's name typed back. --dry-run shows the whole plan. |
| Five-connection cap | A design you build | The agent does not count its own connections. The cap is enforced at the database boundary: a role limit, a pooler and the network. Section 5 shows how, with a measurement. |
| Incident workspace | Not shipped | The timeline, evidence cards and next-action preview in section 6 are a design, and the interactive demo is a simulation with scripted data. No database is connected to it. The agent does not have this interface today. |
| Assistant and MCP server | Lookup only | The site's MCP server looks up this site's own pages. It never connects to a database. It is built but not yet published for download. |
Both are called "database agents", and they are different problems. Mixing them up is how a chat assistant ends up with a superuser login.
| Application agent | Operations agent | |
|---|---|---|
| What it does | Answers users, calls tools, runs for them | Investigates a database and may change it |
| What it stores | Conversations, checkpoints, tool calls, long-term memories | Evidence, hypotheses, change requests, an audit trail |
| Its database role | It is a client: it reads and writes its own tables | It is an operator: it looks at other systems' sessions, locks and settings |
| What goes wrong | Lost state, a memory read for the wrong tenant, a slow vector search | A wrong kill, an index build at peak, a failover that loses writes |
| Read more | Agent memory and state | This page |
An operations agent also needs a place to keep its own incident notes. That store is small and lives apart from the databases it watches.
| Level | The agent may | Examples |
|---|---|---|
| Observe | Read through approved checks, in a read-only session, with timeouts and a connection cap | Connection counts by state, lock chains, top statements, plans from EXPLAIN, replication lag, cloud events and metrics, the deploy log, the playbooks |
| Recommend | Rank causes, name the safest next check, write a change request with a preview, write a handoff | "Most likely a pool problem after the 14:02 deploy. This is the evidence. This is what would disprove it." |
| Execute | Run one allowlisted, approved change through a narrow executor, then verify it | End one named session, cancel one query, build one index, after a named person approved that exact command |
| Stays human | The agent prepares. People decide and, for the highest risks, run it | Failover, forced quorum, rebuilding a member, accepting a data-loss window, rolling back a deploy, granting access, telling customers, closing the incident |
| Out of scope | Not offered to the agent at all | Arbitrary SQL or shell on the database host, reading table contents beyond what a diagnosis needs, any environment other than the one it is configured for, changing its own permissions or limits |
It never raises its own permissions. Rights live in the database and in your cloud's IAM, and people change them through review. If an action needs a right the agent does not have, it says "unavailable: needs this right" and stops. It does not look for another login, ask a human to paste a password into the chat, or try a different tool that happens to work.
A reference design, not a product diagram. The approval and two-login parts match how the DBA agent works. The pooler and network rules are what you add at the database boundary. Step through it.
| Concern | Rule |
|---|---|
| Identity | One identity per environment and per purpose. A read-only login for checks, a separate executor login per action type, none shared with an application or a DBA. Short-lived credentials where the platform issues them, such as IAM database authentication on RDS and Aurora. |
| Secrets | Held by the tools and the secrets manager, never in the model's context, the prompt, the logs or the incident record. |
| Environments | Staging and production are separate agents, logins and networks. A tool built for one cannot be pointed at the other. |
| Observability | The agent is monitored like any production service: its connection count, queue depth, rejected work, tool errors, and the age of the evidence it acts on. |
| The operator | Sees the evidence behind every claim, can reject or edit a request, and has a stop control that halts all tools. The on-call person stays the owner of the incident. |
Every action the agent can take has a tier. The tier decides the login it uses, who approves and how it is verified. Scroll the table sideways on a phone.
| Tier | Examples | Permissions | Approval | Safeguards | Verification |
|---|---|---|---|---|---|
| 0 · Explain | Summarize pasted output, explain a symptom from the lessons | None. No database login and no network path | None | Remove secrets and personal data before pasting. Label the answer as unchecked | The reader checks the claim in the docs or with a read-only check |
| 1 · Read | Connection counts, lock chains, top statements, replication lag, cloud metrics and events | A read-only login: pg_monitor, read-only session, timeouts. Read-only cloud role | None per check. People approve the list of checks once | Fixed, parameterized queries, no free SQL, row limits, the five-connection cap, a deny list as a second check | Each result shows the query and the time. Tests confirm a write attempt is refused |
| 2 · Low-risk, reversible | Post a summary, open a ticket, pause your own batch job. Database changes only if a policy names them | A separate login with the one right it needs | Only for actions a written policy allowlists in advance. Otherwise treat it as tier 3 | Rate limit, cooldown, one at a time, a hard ceiling on size, an alert on every run | A read-only check shows the intended effect. Stop at the first miss |
| 3 · Disruptive | Cancel or end a session, take a replica out of a read pool, scale, change a setting, add an index | An executor login with only the needed right. pg_signal_backend cannot signal superuser sessions | A named person approves the exact command | Preview with target, command, why, risk and undo. Precheck again at apply. One change at a time. A limit on how many sessions or objects one change may touch. A stop control | A read-only check must pass after the change. If not, the agent stops and escalates |
| 4 · High consequence | Failover or promotion, forced quorum, rebuilding a member, deleting data or replication state, privilege changes, arbitrary SQL writes | Not granted by default | Disabled. A person runs it from a documented process, with a second person | The DBA agent refuses these unless the operator passes --allow-high-risk, and then each needs the target's name typed back. For a pilot, leave the flag off | A person verifies against the runbook, not the agent |
| What it does | Tier | Control |
|---|---|---|
| Playbook read steps, HA status reads | 1 | Read-only session, timeouts, deny list |
| End an idle-in-transaction session, cancel a query, add an index | 3 | Change request, named approver, precheck, separate login, verify, audit line |
| HA changes (switchover, rejoin a node) | 3 | Typed approval, read-only check after each change, JSONL audit log |
| Failover, forced quorum, rebuild, forced replica set config, Orchestrator recover | 4 | Off. Needs --allow-high-risk and the target's name typed back |
| Drop an inactive replication slot | 4 under this model | The agent can propose it, with a named approver. It deletes replication state, so a pilot should leave it out of the allowed fixes, or require a second reviewer |
The DBA agent asks a person for every fix. It does not use tier 2 for database changes. Tier 2 is a policy option for teams that choose it.
The agent should be unable to take more than five PostgreSQL server connections, however many workers or replicas run, and unable to raise that number itself. A setting in the agent's own code or pool size does not do that: a bug, a second replica or a script that opens its own connection walks around it. The limit has to be enforced where the agent cannot reach it, at the database boundary. Four layers do that together.
CONNECTION LIMIT, so a superuser agent has no cap at all.CONNECTION LIMIT 5 on that role, as the backstopPostgreSQL refuses the sixth normal connection for the role, across all databases. The documentation says the limit is enforced only approximately: if two sessions start at the same moment with one slot left, both may fail. That fails closed, not open. Prepared transactions and background workers do not count. CREATE ROLEmax_user_connections = 5 keeps the role at five server connections across all its pools and databases. Use a dedicated PgBouncer for agents, so its queue is the agent's queue only.pg_hba.conf, and the role limit is the last line even if it does not.PgBouncer has two kinds of limit, and mixing them up is the common mistake. A server connection is a real PostgreSQL backend. A client connection is a worker talking to PgBouncer. Many clients can share few servers: that is the point of a pooler. Queued clients wait inside PgBouncer and are not PostgreSQL connections.
| Setting | Kind | What it bounds |
|---|---|---|
max_user_connections | Server | Server connections per user, across all databases. This is the cap |
default_pool_size | Server | Server connections per user and database pair. Alone it is not the cap: two databases mean two pairs |
max_db_connections | Server | Server connections per database, whatever the user. Useful when the agent has its own database |
max_client_conn | Client | Client connections the whole PgBouncer process accepts, any user. This bounds the queue. A dedicated PgBouncer makes it the agent's queue |
max_user_client_connections | Client | Client connections per user. Added in PgBouncer 1.24.0, so it is not in 1.22 |
query_wait_timeout | Queue | Seconds a query waits for a server connection. After that, PgBouncer disconnects the client. The default is 120, and 0 means wait forever, so set it |
state-changing Run once by a DBA. PostgreSQL 16. Self-managed, and on RDS, Aurora and Cloud SQL as the admin user the service gives you, which is not a true superuser there.
CREATE ROLE dba_agent LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION CONNECTION LIMIT 5; -- set the password from your secrets manager GRANT pg_monitor TO dba_agent; -- statistics and settings views, no table data ALTER ROLE dba_agent SET default_transaction_read_only = on; ALTER ROLE dba_agent SET statement_timeout = '5s'; ALTER ROLE dba_agent SET lock_timeout = '1s';
state-changing Self-managed only: pg_hba.conf, then a reload. First match wins, so the reject line goes after the allow line. On RDS, Aurora and Cloud SQL you cannot edit this file: use security groups or VPC firewall rules so that only the pooler's address reaches port 5432 for the agent.
# only the pooler host may connect as dba_agent host all dba_agent 10.0.5.20/32 scram-sha-256 host all dba_agent 0.0.0.0/0 reject
PgBouncer, a dedicated instance for the agent. state-changing config. Version labeled: the limits below were tested on PgBouncer 1.22.0 with PostgreSQL 16.
; pgbouncer.ini (tested on PgBouncer 1.22.0) [databases] app = host=db-primary port=5432 dbname=app postgres = host=db-primary port=5432 dbname=postgres [pgbouncer] pool_mode = transaction ; a server connection is held only for one transaction max_user_connections = 5 ; SERVER connections per user, all databases: the cap default_pool_size = 5 ; per user/database pair, so this alone is not the cap max_client_conn = 20 ; CLIENT connections this process accepts: the queue bound query_wait_timeout = 3 ; seconds a queued query waits before it is dropped reserve_pool_size = 0 ; the default: no extra connections auth_type = scram-sha-256 ; the sandbox used trust. Do not auth_file = /etc/pgbouncer/userlist.txt admin_users = pgb_admin ; not the agent's role
When five server connections are busy, new work waits in the queue, up to max_client_conn clients and up to query_wait_timeout seconds. When the queue is full, new clients are refused at connect. Nothing opens a sixth connection to PostgreSQL. The agent has to treat both outcomes as "busy", not as an error to push through.
auth_type = trust. Role dba_agent with CONNECTION LIMIT 5. 30 workers, each running SELECT pg_sleep(2), split across two databases, all at the same time.
| What was measured | Result |
|---|---|
Peak server connections for dba_agent in pg_stat_activity | 5 |
| Workers that finished | 10 |
Workers that queued, then got query_wait_timeout | 10 |
Workers refused at connect with no more connections allowed (max_client_conn) | 10 |
| Total time | about 4 seconds |
Then 7 direct connections to PostgreSQL as dba_agent, bypassing the pooler | The first was refused: FATAL: too many connections for role "dba_agent" |
max_client_conn = 20) and ten were turned away at the door. Of the twenty, ten ran in two waves of five, two seconds each. The other ten waited past the three-second limit and were dropped (derived from the settings, not separately measured). The direct connection was refused because PgBouncer's five idle server connections already used the role's limit. That is the backstop working, and it also shows that your own break-glass access must use a different role.A refused or timed-out request is retried a few times, with a delay that grows and is randomized, so that many workers do not come back at the same moment. These numbers are an example, not a measurement.
attempt 1: now on "no more connections allowed" or query_wait_timeout: wait a random time between 0 and min(8 s, 0.5 s x 2^attempt) (full jitter) at most 3 retries after the last retry: report "busy, try again in N seconds", mark the check "deferred" after 3 busy answers in a row: stop sending for 60 s (circuit breaker)
read-only PgBouncer admin console, connect to the pgbouncer database as an admin or stats user. Any platform. The column names come from the current PgBouncer docs. Run the command on your version to see which it shows.
SHOW POOLS; -- per database and user: cl_active, cl_waiting (the queue), sv_active, sv_idle, maxwait SHOW USERS; -- per user: max_user_connections, current_connections (server), current_client_connections
read-only PostgreSQL, any platform. Run as a role in pg_monitor, or you will not see other roles' sessions in full. Docs: pg_stat_activity.
SELECT usename, application_name, state, count(*) FROM pg_stat_activity WHERE usename = 'dba_agent' GROUP BY 1, 2, 3; SELECT rolname, rolconnlimit, rolsuper FROM pg_roles WHERE rolname = 'dba_agent';
| Signal | Where to read it | A starting alert (tune it) |
|---|---|---|
| Agent server connections | SHOW USERS current_connections, or pg_stat_activity | At 5 for more than 5 minutes. Touching 5 in a burst is normal |
| Queue depth | SHOW POOLS cl_waiting | Above 0 on consecutive scrapes |
| Queue wait | SHOW POOLS maxwait (seconds the oldest client has waited) | Over half of query_wait_timeout |
| Rejected or dropped work | Agent tool errors, PgBouncer log | Any rise. Show it to the operator as "checks deferred" |
| Bypass attempts | PostgreSQL log, too many connections for role, or a connect from an address that is not the pooler | Page security. It means something is going around the pooler |
CONNECTION LIMIT, give each user its share in PgBouncer (SHOW USERS reports a max_user_connections per user, and the configuration reference has the per-user form), and send both through the same pooler.superuser_reserved_connections). If the app has taken every slot, a new agent connection fails too. A warm pooled connection (min_pool_size = 1) helps, and a human's break-glass role is the fallback. Connection settingsThe agent is useful in an incident when it connects evidence to a decision, not when it talks. This is the design. The DBA agent does not have this interface today. The demo below is a simulation with scripted data.
| Mode | What it does | Needs a database? |
|---|---|---|
| Learn | Explains a symptom or concept and links to the lessons | No |
| Investigate | Runs approved read-only checks and builds an evidence-backed diagnosis | Read-only access. The demo uses none |
| Act | Proposes, or runs only what the policy allows, after showing the preview and getting approval | Yes, with a separate executor login |
Pick an incident. Start in Investigate, run a few checks, open "Why?" on a hypothesis, then go to Act. Try the "Symptoms get worse" outcome and the Stop button. Everything is scripted and nothing is connected.
Checkout is failing with "sorry, too many clients already". This is the same incident the simulation runs, with the real commands. The numbers in the simulation are scripted, not measured. Commands are for PostgreSQL 16 and work on self-managed servers, RDS, Aurora and Cloud SQL unless a note says otherwise.
read-only Connections against the limit. Any platform. Prerequisite: pg_monitor. Impact: a read of the statistics view.
SELECT count(*) AS in_use,
current_setting('max_connections')::int AS max_connections,
current_setting('superuser_reserved_connections')::int AS reserved
FROM pg_stat_activity WHERE backend_type = 'client backend';
read-only By application and state. The oldest transaction start shows who is holding slots.
SELECT application_name, state, count(*), min(xact_start) AS oldest_xact FROM pg_stat_activity WHERE backend_type = 'client backend' GROUP BY 1, 2 ORDER BY 3 DESC;
read-only Who blocks whom. Query text can hold customer values: the agent keeps a fingerprint and drops the literals before it stores or posts anything.
SELECT pid, pg_blocking_pids(pid) AS blocked_by, wait_event_type, state,
now() - xact_start AS xact_age
FROM pg_stat_activity WHERE cardinality(pg_blocking_pids(pid)) > 0;
read-only Top statements. Needs the pg_stat_statements extension (available on RDS, Aurora and Cloud SQL, loaded through shared_preload_libraries on self-managed servers). PostgreSQL 13 and later use mean_exec_time. Older versions call it mean_time.
SELECT queryid, calls, round(mean_exec_time::numeric, 1) AS mean_ms FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 5;
| Cause | What you see | The check that separates it | What rules it out |
|---|---|---|---|
| Traffic increase | Requests and statement calls rise together | Request rate against the same hour last week, and statement calls | Request rate is flat |
| Retry storm | Statement calls rise while requests stay flat. Many connection attempts a second | Calls against requests. Connection attempts, if log_connections is on | Calls follow requests one to one |
| Bad query plan | One statement's mean time jumps. CPU is high. Connections are normal | pg_stat_statements by queryid, then EXPLAIN | Statement times are unchanged |
| Lock wait | Sessions wait on a lock, CPU is low, one blocker is idle in a transaction | pg_blocking_pids | Nothing is waiting on a lock |
| Pool problem | Connections near the limit, mostly idle or idle in transaction. Pods times pool size passes the limit | Connections by state and application, the deploy diff, whether a pooler exists | Connections are low, slots are free |
In this incident the evidence points at a pool problem made worse by retries, with a lock chain on top. Six pods of 40 connections is 240 possible connections against 197 usable (derived). The traffic and plan hypotheses are ruled out.
max_connections (a restart, more memory, hides the cause), raising its own cap, ending all 151 idle sessions at once (the blast radius is above the limit of 5 sessions per change).state-changing The approved action. Self-managed: the role needs pg_signal_backend or must own the session. On RDS, Aurora and Cloud SQL, use the role your provider allows to signal other sessions, and check its docs. Neither can signal a superuser's session. Impact: the session ends, its open transaction rolls back, the app sees a connection error and may retry. It cannot be undone.
SELECT pg_terminate_backend(48213);
The agent has six checks to run. It keeps at most 4 in flight, and PgBouncer allows 5 server connections. If another worker is also using the role, a check waits in the queue for up to 3 seconds. If the queue is full, it is refused, and the agent shows "checks deferred" instead of trying a side door. It does not need more connections to finish: each check is short.
SHOW USERS), and no check was refused for longer than expected.idle_in_transaction_session_timeout on the application role.Each guardrail has a limit of its own, so none of them is enough alone. Approval can be rubber-stamped. A read-only session can still run a query that loads the server. Logging records a mistake after it happens. A tier label does not know what the workload is doing right now.
| Risk | Guardrail | Where it falls short |
|---|---|---|
| Wrong identity | Separate identities per environment and purpose. Least privilege. Short-lived credentials | A leaked credential works until it expires. The network and the role limit still apply |
| Arbitrary execution | An explicit tool allowlist. Parameterized commands. No shell and no free SQL | One "run this query" tool undoes the whole list |
| Disruptive change | Approval workflow with a preview, by a named person | People approve what they do not read. Keep requests few and the evidence next to the command |
| Stale or wrong target | Re-validate the target and the evidence right before the action. Check backend_start, not just the pid | Check and action are not one atomic step. Keep each action small and idempotent |
| Duplicates and storms | Dedupe alerts by fingerprint. One open change per target. Rate limits, timeouts, no automatic retry of a change | A bad fingerprint hides a second real incident |
| Prompt injection | Treat logs, SQL comments, ticket text, row values and runbooks as data. Text cannot add a tool or change a policy. The model never holds credentials, and the policy engine, not the model, decides what is allowed | You cannot prove a model will never follow hostile text. So no path to a change depends on the model alone |
| Data exposure | Tenant isolation. Fingerprints and counts, not row values. Redact before storing or posting | Query text and error messages can still carry values. Test the redaction |
| Model or tool outage | The agent is optional. Alerts still page people. The playbooks work without it | People lose the speed-up. Practice without it |
| Wrong diagnosis | Show the evidence for and against. Track the false diagnosis rate | A confident wrong answer is still persuasive |
| Partial execution | One action at a time. Verify after each. Stop at the first failure. State the undo, or "none", in the preview | Some changes cannot be undone |
| Runaway agent | A kill switch that stops every tool, and a way to disable the logins (ALTER ROLE dba_agent NOLOGIN stops new logins, so end the open sessions too) | It only helps if someone knows it exists. Practice it |
| No record | An audit trail: who approved, the command, the target, the evidence, the result. Credentials and query literals redacted | An audit log the agent can edit proves little. Write it somewhere it cannot |
| Untested behavior | Replay past incidents, run simulations, and in production start in shadow mode where the agent proposes and people compare | Past incidents are not tomorrow's. Keep adding cases |
| Operator is stuck with it | The operator can inspect, reject, edit or stop any proposal | Only works if the controls are one click away |
| Silent failure | An unavailable action says why: "needs this right", "not enough evidence", "cap is full" | A silent skip looks like "nothing to do" |
DB ops database operations, Platform platform and security, Service the teams that own the applications.
CONNECTION LIMIT 5, is not a superuser, and owns nothingThese are suggested definitions. This site has not measured them for any real deployment.
| Signal | How to count it | What to look for |
|---|---|---|
| Unsafe-action rate | Actions a reviewer says should not have been proposed or run, divided by actions proposed | Zero for executed actions. Any miss triggers a review |
| Acceptance and override rate | Proposals approved as written, and proposals rejected or edited | Near-100% acceptance with fast approvals may mean nobody is reading |
| False diagnosis rate | Incidents where the leading hypothesis was wrong at close | By incident type. A rising trend after a change |
| Time to mitigation | Alert to verified mitigation | Against the same incident type before the agent |
| Post-action regressions | Actions followed by a failed verification or a related alert in a set window | Any, and what the precheck missed |
| Agent connections, queue depth, rejected work | SHOW USERS, SHOW POOLS, agent tool errors | The cap is hit often: the checks are too heavy, or too many run at once |
The playbooks have an "Automate it" list on each page. I went through every line that says an agent could act and classified it. Four classes: Observe (reads), Recommend (writes a proposal for a person), Approval-gated (a change a person approves), Strict policy (potentially automatable only under a written policy). A line that says "an agent can" describes what is possible. It never grants autonomous production changes. Where the wording promised more than that, I changed it at the source: the playbooks and runbooks.json.
| Suggestion | Class | Prerequisites | Impact | Approval | Verification |
|---|---|---|---|---|---|
Collect and post evidence: the one-minute snapshot (CPU), top reader (I/O), logs from before a restart (memory), Patroni and kernel logs after a failover, RDS events, pod describe and logs, cluster.status(), replica set voters and oplog window, etcd health, plan comparison, big-key sample, Cassandra repair history, nightly recall test | Observe | Read-only login, timeouts, approved checks. For Redis, sample on a replica with commands that do not block | A small read load. Text may carry sensitive values, so redact | None per run. People approve the check list once | The post shows the command and the time |
| Find the head blocker and post who it is | Observe | As above | A read | None | The blocker is named with its age and what it holds |
| Track wraparound age and open a ticket. Open Cassandra repair tickets | Recommend | Write access to the ticket system only, not the database | A ticket | None. A person owns the ticket | Dedupe by fingerprint, so there is one open ticket |
| End sessions idle in a transaction past a threshold | Approval-gated. Strict policy only through idle_in_transaction_session_timeout | Executor login with pg_signal_backend. A precheck on pid and backend_start. A limit on sessions per change | Open transactions roll back. The app sees errors and may retry | A named person. For no person at all, a DBA sets the timeout on the application role, and the database does it | Sessions gone, locks gone, error rate down |
| Grow a cloud volume by a fixed step when time to full is short | Strict policy, otherwise approval-gated | One fixed step, a hard ceiling, a cooldown, an agreed cost owner, and a notice to a person | Cost goes up. Growing is usually one way, so check your provider | Pre-approved by policy, or a person | Free space and time to full recomputed. The volume reports the change complete |
| Take a replica out of the read pool on lag, and put it back | Approval-gated. Strict policy with limits | Never the last healthy replica. A delay before putting it back. A limit on runs per hour | The other replicas and the primary take more load. Routing changes | A person, or a policy that has the limits above | Lag recovers, other nodes cope, errors do not rise |
| Pause a batch job when lag or disk latency rises | Strict policy | The job owner builds the guard into the job. A rule for resuming | The job runs late. The database is not changed | None. It is the job owner's own code | Lag falls and the job resumes |
| Cancel a DDL that waits on a lock | Approval-gated. Better: lock_timeout in the migration | The migration sets a few seconds of lock_timeout itself | The DDL fails and must be retried at a quiet time | A person for a tool-side cancel. None for the timeout, set in code review | The queue behind the DDL clears |
Run ANALYZE after a bulk job | Strict policy | A step of the job, run by the job's own login, on named tables | A short read load. Plans may change | None, owned by the job | The table's statistics time is new |
| Prepare the async switch when a sync standby is dead | Recommend. The switch is a person's decision | The data-loss window stated in the proposal | Lower durability from then on | A person, ideally two | Writes continue. Replication state is checked |
| Propose removing an InnoDB Cluster member with a growing applier queue | Recommend. An HA change, so a person decides | Clear evidence, and the plan that --dry-run shows | Cluster capacity and quorum change | Typed approval in the DBA agent | The cluster status is healthy afterwards |
| Pre-deploy check that blocks a deploy, and a CI plan check | Strict policy (a CI gate) | The service team owns the check. It runs on a copy of statistics | A deploy is blocked or flagged | None. It is the team's own pipeline | The check ran on every deploy |
Patroni remove_data_directory_on_rewind_failure | Not an agent. A configuration choice | Decided on purpose by the cluster owner | It deletes the data directory on a failed rewind | Part of the config review | Test it in a rehearsal |
The site's MCP server answers questions from this site's pages: which database, how big, a query review, which lesson. It never gets a connection string and cannot run anything on a database. review_query reads SQL you paste and applies the Query coach rules to the text. It is built and works on a local machine, but the download is not published, so there is nothing to install yet. For an assistant that reads the web, llms.txt is live today.
CONNECTION LIMIT), predefined roles, server signaling functions, monitoring statistics, pg_hba.conf, connection settings; PgBouncer configuration, admin console commands and changelog. The connection test is the measurement above. The simulation and the retry numbers are illustrative.How do I run it in production? What to check when it is slow or broken, where it runs and what it costs, how big it must be, pooling, backups, security, upgrades and other changes made safely.