最新资讯
computerworld.com Box 发布 Architect:用自然语言构建业务流程工作流 the-decoder.com METR 称 Anthropic 或已在 7 月越过自身 AI 加速预警阈值 towardsdatascience.com 用 Ollama 和 Python 构建你的第一个多工具 AI Agent the-decoder.com Thinking Machines 的 Inkling 2 Small 称霸西方开放权重模型 dev.to 为 CI/CD 构建 AI 质量门禁 dev.to Kakao 发布面向 AI Agent 的决策模型 Kanana-2-v-decide computerworld.com Microsoft 对 Copilot Chat 企业用户扩大未公开的使用限制 pub.towardsai.net Google 发布 Gemini 4 Carbon:主打网络安全能力的前沿模型 gradientflow.com METR 研究:AI 正在加速构建 AI 的团队本身 www.infoq.com GitLab 19.5 将 Agentic 开发纳入 DevOps 平台的治理体系 aiacceleratorinstitute.com 研究:AI Agent 的复杂流程编排可能反而是问题所在 pub.towardsai.net MongoDB 推出 Vercel AI SDK 集成:为 AI 应用提供持久记忆
多元动态
登录 注册
智能体 pub.towardsai.net · @Maya Lin

DROP TABLE 失效模式:为何自主 SRE Agent 不应被授予 DDL 权限

原文 我的收藏

文章复盘一次自主 agent 自动回滚事故:agent 在清理迁移锁时因日志刷屏丢失指针上下文,对生产事务库误执行 DROP TABLE ... CASCADE,而非作用于 staging 分区,驱动返回 HTTP 200,数据在毫秒内被清空。作者据此主张用确定性网关强制状态机不变量,限制自主 LLM agent 在数据库迁移、schema 部署和故障分诊中的直接 DDL 权限。

AI推荐理由 输入提供了具体事故细节:自主 agent 在自动回滚中因日志淹没丢失指针上下文,对生产库执行 DROP TABLE ... CASCADE,驱动返回 HTTP 200,数据毫秒级被清空,并主张需要确定性网关来强制状态机不变量。这是对自主 SRE agent 权限边界与 DDL 操作风险的具体工程教训,对 Agent 落地安全设计有直接参考价值;但来源为 Medium 个人文章,事故细节无法独立验证,且未给出可复现证据或具体系统名称,需保留其单方叙述的不确定性。

78

正文

DevOps Postgresql Software Engineering Database Artificial Intelligence The DROP TABLE Failure Mode: Why Autonomous SRE Agents Can’t Be Trusted With DDL Keys An autonomous agent attempted an automated schema rollback, lost pointer context under log flooding, and dropped a live production table. Here is the post-mortem and the deterministic gateway needed to enforce state-machine invariants. Maya Lin 5 min read · Just now -- Listen Share Press enter or click to view image in full size Engineering teams are increasingly assigning autonomous LLM agents to automated database migrations, schema deployments, and incident triage. By combining generative models with terminal access and database connection strings, teams attempt to build self-healing infrastructure that resolves migration lockups and deadlocks without human intervention. During a recent automated rollback, this pattern caused an immediate production outage. An autonomous agent tasked with clearing a migration lock executed a catastrophic DROP TABLE ... CASCADE command against a live transactional database instead of its staging partition. The driver returned an HTTP 200 OK. The data was wiped in milliseconds. Below is the technical post-mortem of how context degradation leads to pointer confusion in database agents, why prompt-level safety instructions fail to constrain destructive SQL operations, and how to implement deterministic DDL circuit breakers at the database gateway. 1. Incident Architecture: The Rollback Protocol The deployment pipeline utilized an autonomous agent integrated with a PostgreSQL primary cluster and staging replicas. The agent was granted a database role with DDL permissions to execute schema migrations and manage rollbacks. The Trigger During a rolling update, a schema alteration script attempted to add an unindexed foreign key to a high-throughput transactional table (orders_v2). The operation encountered concurrent write contention and reached its lock timeout: ERROR: canceling statement due to lock timeout CONTEXT: while adding foreign key constraint "fk_customer_id" to table "orders_v2" SQLSTATE: 55P03 The incident triage loop picked up the error payload and passed it to the agent alongside the active runbook: Runbook Directive: When a migration statement cancels on lock timeout: 1. Terminate all orphaned backend connections holding table locks. 2. Drop the staging temporary rollback table created during initialization. 3. Re-run the pre-migration verification checklist. The Context Flooding Breakdown Under standard execution, the model should target orders_v2_staging_tmp. However, before executing the rollback, the agent attempted three consecutive retries. Each failed retry appended raw connection logs, pg_stat_activity dumps, and stack traces into the agent’s active context window — injecting over 6,000 tokens of dense, repetitive error logs: 2026-09-18 10:14:02 UTC [8421]: ERROR: statement timeout on relation "orders_v2" 2026-09-18 10:14:03 UTC [8422]: LOG: process 8422 still waiting for AccessExclusiveLock on relation "orders_v2" Under severe context dilution, self-attention across long token spans splits. When the agent generated the SQL remediation tool call, the entity weight for "orders_v2" overwhelmed the weight for "orders_v2_staging_tmp". The agent constructed and executed the following payload: DROP TABLE orders_v2 CASCADE; The PostgreSQL engine received the command over an authenticated connection, verified that the user had DROP authority, resolved dependencies via CASCADE, and dropped the primary operational table. Get Maya Lin’s stories in your inbox Join Medium for free to get updates from this writer. Subscribe Subscribe Remember me for faster sign in The agent verified that the lock state was cleared, marked the triage ticket as “Resolved,” and exited. 2. Failure Analysis: Attention Degradation vs. Destructive Authority This incident exposes a fundamental architectural flaw: relying on generative models to differentiate between safe and destructive DDL commands based on prompt context. Attention Entropy Under Incident Conditions An autoregressive model generates tool arguments by predicting the most probable token continuation given context history: When error logs saturate the context buffer with references to the target production table (orders_v2), the attention distribution shifts toward the high-frequency entity. The model does not retain a verified symbolic pointer to the staging partition; it generates the identifier that appears most salient across its recent token sequence. Syntactic Correctness vs. Operational Safety Schema validation libraries like Pydantic and SQL linters are incapable of detecting this failure mode: class ExecuteSQLPayload(BaseModel): query: str target_database: str timeout_seconds: int = 30 DROP TABLE orders_v2 CASCADE; is syntactically flawless. Linters verify syntax; they cannot determine whether a table name represents an active revenue pipeline or an ephemeral sandbox partition. 3. Architectural Mitigation: Deterministic DDL Circuit Breakers Generative models must never be provisioned with direct, unmediated DDL write credentials to transactional databases. The agent’s role must be strictly confined to proposing migration steps. Every SQL statement must pass through an out-of-band execution gateway that enforces deterministic structural AST validation before packets reach the database engine. ┌────────────────────────────────────────────────────────┐ │ Autonomous SRE Agent │ │ (Generates DDL Proposal) │ └───────────────────────────┬────────────────────────────┘ │ Raw SQL Statement ▼ ┌────────────────────────────────────────────────────────┐ │ Database Safety Gateway │ │ │ │ 1. SQL AST Compilation │ │ - Parses statement via pg_query AST parser │ │ - Identifies Statement Type: DropTableStmt │ │ │ │ 2. Invariant & Target Verification │ │ - Assert: Statement != DROP/TRUNCATE on Prod │ │ - Assert: Target ∉ Protected Entity Set │ │ - Verify Target Schema == "staging_tmp" │ │ │ │ 3. Deterministic Connection Severing │ │ - Instantly drops session on invariant failure │ └───────────────────────────┬────────────────────────────┘ │ Authorized Migrations Only ▼ ┌────────────────────────────────────────────────────────┐ │ Production PostgreSQL Engine │ └────────────────────────────────────────────────────────┘ Gateway Invariant Enforcement The deterministic gateway inspects the Abstract Syntax Tree of the proposed query before routing to the database socket: import pglast from pglast import parse_sql, ast class DatabaseExecutionGateway: def __init__(self, protected_relations: set): self.protected_relations = protected_relations def validate_and_gate_query(self, raw_sql: str) -> None: try: parsed = parse_sql(raw_sql) except Exception as e: raise UnparseableQueryException("Malformed SQL rejected at gateway boundary.") for statement in parsed: # Check for destructive DDL commands if isinstance(statement, ast.DropStmt): for target in statement.objects: # Extract relation name from AST node relation_name = target[-1].string if isinstance(target, list) else target.string if relation_name in self.protected_relations: self._trigger_killswitch(raw_sql, relation_name) def _trigger_killswitch(self, sql: str, target: str) -> None: # Instantly terminate session and write immutable audit alert raise DestructiveOperationBlocked( f"Deterministic Circuit Breaker: Blocked unverified DDL drop targeting protected relation '{target}'." ) The Operational Takeaway An autonomous agent does not possess intuition, fear of downtime, or operational awareness of your data schema. When trapped in an error loop, it executes whatever syntactic sequence satisfies its objective function — even if that means dropping the core tables that power your business. Natural language prompts cannot prevent destructive state mutations; deterministic proxy gates can. If you do not decouple your AI agents from raw database execution keys, an unhandled error loop will eventually take your production database down with it.

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容