Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for MySQL Difficulty: Advanced ClaudeChatGPTCursor

MySQL Errant GTID Transaction Reconciliation Prompt

Detect and safely reconcile errant transactions (GTIDs on a replica the source never had) that block failover or break GTID replication.

Target user
DBAs resolving GTID replication errors and errant transactions
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior MySQL/MariaDB DBA who resolves GTID replication breakage. You understand GTID_EXECUTED, GTID_PURGED, the difference between a source's and a replica's UUID:transaction sets, how errant transactions arise (a write executed directly on a replica, or a former primary), and the two reconciliation paths: inject an empty transaction to neutralize, or replay the missing data onto the source.

I will provide:
- GTID_EXECUTED from each node (source and replicas): [PASTE `SELECT @@GLOBAL.GTID_EXECUTED` PER NODE]
- The replication error, if any (e.g. cannot replicate because the source purged required GTIDs, or a failover tool refuses to promote due to errant GTIDs): [PASTE]
- Server UUIDs and which node is intended to be the source: [DESCRIBE]
- Whether you can inspect binary logs on the node holding the errant GTID: [YES/NO]

Work through this:

1. **Compute the errant set.** Using GTID_SUBTRACT logic, identify which UUID:tx-ranges exist on a replica but not on the source (or vice versa). Name the exact errant GTIDs. Show the GTID_SUBTRACT queries you would run.
2. **Determine what the errant transaction did.** Instruct how to read it from the binlog (mysqlbinlog with --include-gtids) so the decision is informed by real content, not assumption. A DDL/DML that wrote user data must NOT be blindly erased.
3. **Choose the reconciliation path.** If the errant transaction is a harmless artifact (e.g. an accidental read-only or already-present change), neutralize it by injecting an empty transaction with that GTID on the source, then let it propagate. If it wrote data that must survive, replay that data onto the source through normal writes so the topology re-converges.
4. **Prevent recurrence.** Recommend super_read_only on all replicas so no accidental writes create new errant GTIDs, and review how the errant one was introduced.
5. **Verify convergence.** After reconciliation, confirm every node's GTID_EXECUTED is consistent and replication resumes cleanly.

Output: (a) The exact errant GTID set and the GTID_SUBTRACT queries used, (b) What the errant transaction contained and the decision it drives, (c) The chosen reconciliation steps with commands, (d) Recurrence prevention, (e) Verification and rollback caution.

Guardrails: never inject an empty transaction to erase an errant GTID until you have read the transaction from the binlog and confirmed it holds no data worth keeping; enable super_read_only on replicas to stop new errant writes; treat gtid_purged/RESET MASTER as topology-wide destructive and confirm every node's GTID set before touching them.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Errant transactions are one of the most misunderstood corners of GTID replication, and the usual “fix” copied from a forum — inject an empty transaction to make the error go away — can silently destroy real data. This prompt puts the mandatory investigation step first: read the errant transaction out of the binlog and find out what it actually did before deciding how to neutralize it. That single discipline is the difference between a clean reconciliation and quiet data loss.

By making the model compute the errant set explicitly with GTID_SUBTRACT rather than eyeballing UUIDs, the prompt keeps the diagnosis precise. GTID sets are exactly the kind of dense, error-prone data where a wrong node or a transposed range causes a much bigger problem, so naming the exact GTIDs and showing the queries used keeps the operator oriented.

The prompt also treats prevention as part of the fix. Errant transactions almost always come from a write that reached a replica that should have been read-only, so recommending super_read_only across replicas addresses the root cause rather than just the symptom. The guardrails around gtid_purged and RESET MASTER reflect that these commands are topology-wide landmines, keeping a human firmly in control of any irreversible step.

Related prompts

More MySQL prompts & error guides

Browse every MySQL prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.