How to Fix MySQL Error 3991 (ER_RPL_ASYNC_RECONNECT_AUTO_POSITION_OFF)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mysql error 3991 when you turn on async replication failover without auto-positioning. To fix it, you must enable source auto-positioning on the replica channel first. Database teams rely on async failover to keep replicas running when a source fails. Still, the database engine blocks this feature if your replica tracks file positions manually. You need global transaction identifiers so the replica can switch sources without losing data. Why mysql error 3991 happens in replication My

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You see mysql error 3991 when you turn on async replication failover without auto-positioning. To fix it, you must enable source auto-positioning on the replica channel first.

Database teams rely on async failover to keep replicas running when a source fails. Still, the database engine blocks this feature if your replica tracks file positions manually. You need global transaction identifiers so the replica can switch sources without losing data.

Why mysql error 3991 happens in replication

MySQL logs this issue under the symbol ER_RPL_ASYNC_RECONNECT_AUTO_POSITION_OFF and SQLSTATE HY000. The engine triggers mysql error 3991 when a replication change statement lacks auto-position settings. Async connection failover lets a replica switch to a new source node on its own.

If a replica uses old binary log file names and offsets, it cannot switch safely. Each source server maintains its own binary log files and local position numbers. A position number from the old source makes no sense on the new source.

Because of this risk, the database refuses to enable automatic failover on that channel. It requires global transaction identifiers to track which changes the replica already has. Auto-positioning uses those global identifiers to match transactions across any server in your cluster.

How to diagnose the replication channel state

Before you change anything, check the current replication status on your replica node. Look at the performance schema replication connection table to inspect your active channels. You want to see whether auto-positioning is off for the failing channel.

Next, check whether both the source and the replica use global transaction identifiers. Every node in the failover list must have global transaction identifier mode turned on. They also need the setting that enforces transaction consistency across all writes.

MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If any server in the group uses anonymous transactions, you must convert them first. Check the replica status output to confirm no errors exist in the relay log. Taking a few minutes to check these states prevents broken replication later.

How to fix the error safely in production

Fixing this error requires a brief pause on the replica channel. You do not need to stop the source database or interrupt live user traffic. First, stop the replication threads on the replica channel you want to update.

Wait for the replica to finish applying any pending events in its relay log. Once the channel stops cleanly, run a statement to change the replication source settings. Set both the source auto-position option and the connection auto-failover option together.

After you apply the change, start the replication threads on that channel again. Check the replica status table to confirm the input and output threads run fine. Make sure your team runs these admin commands with least-privilege roles instead of root.

Avoid disabling safety checks or skipping transactions just to force a connection through. Keep a clear audit log of who ran the replication change and when. During checks on user tables, ensure query tools mask emails and phone numbers.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

What does ER_RPL_ASYNC_RECONNECT_AUTO_POSITION_OFF mean?

It means you tried to enable async replication failover while auto-positioning was turned off. The database blocks this change because failover requires global transaction tracking to work safely.

Does fixing mysql error 3991 cause downtime on the primary database?

No, you only need to pause the replication threads on the replica server. Your primary database continues to read and write data for your apps as normal.

Can I use async connection failover with binary log file positions?

No, MySQL does not allow automatic connection failover when you use file positions. You must switch your cluster to global transaction identifiers and enable auto-positioning first.

The query runs. The emails stay hidden.