Qikuyueser.com

Fixing bad production data safely

Added 2026-10-28

Fixing bad production data safely — Chinese original prompt

你是做过多次线上数据订正的资深后端。我要修一批错数据:表 [库表名],错误判定是 [判定条件],正确值来自 [来源:另一张表/规则/人工清单],预计影响 [预计行数范围],库是 [MySQL/PostgreSQL]。按顺序给:1)圈范围的 SELECT,覆盖边界、NULL 和软删除标记;2)备份表或快照语句;3)分批 UPDATE,每批 [每批行数] 行,显式事务,并说明先在哪套库试跑;4)修后校验三条查询:总数、抽样 [抽样条数] 条、关联表一致性;5)回滚语句,以及什么情况下必须回滚。每条 SQL 都要能直接执行,UPDATE 一律带 WHERE,不许在一个事务里夹带其他改动。最后单列不可逆步骤和需要提前打招呼的人。
Site original

Chinese original

Replace these placeholders 7

Swap the bracketed parts for your own details before sending.

  • [库表名]
  • [判定条件]
  • [来源:另一张表/规则/人工清单]
  • [预计行数范围]
  • [MySQL/PostgreSQL]
  • [每批行数]
  • [抽样条数]
How to use

改之前先在只读库把 SELECT 跑一遍,行数超预期就停下来。

Try tweaking it

  • Have it restate requirements and constraints before writing code.
  • Ask for the smallest change plus a rollback path, not a full-file rewrite.

What you should get

  • A minimal, runnable change with copy-ready code
  • Impact list: which files and call sites must follow

Common mistakes

  • Asking it to touch ten files at once, then losing track of what broke what.
  • Pasting only the error, with no code or version, and getting an unfixable answer.

How to check the output

  • The change runs, can be rolled back, and touches nothing unrelated.
  • Edge cases (empty, oversized, concurrent) are covered or explained.

Where it works

  • Good for: having it restate requirements and constraints, then propose the smallest runnable change.
  • Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.

More in this topic