How to Fix MySQL Error 3117 (ER_ENFORCE_GTID_CONSISTENCY_WARN_WITH_ONGOING_GTID_VIOLATING_TX)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 3117 when you change GTID rules while incompatible transactions still run. To fix it, wait for active transactions to finish or stop the offending queries first. Database teams often see this warning when they prepare a server for GTID replication. MySQL uses SQLSTATE HY000 for this event and outputs a specific message. The message says there are ongoing transactions that violate GTID consistency. Understanding why the engine flags these tasks helps you switch modes without

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 get mysql error 3117 when you change GTID rules while incompatible transactions still run. To fix it, wait for active transactions to finish or stop the offending queries first.

Database teams often see this warning when they prepare a server for GTID replication. MySQL uses SQLSTATE HY000 for this event and outputs a specific message. The message says there are ongoing transactions that violate GTID consistency. Understanding why the engine flags these tasks helps you switch modes without downtime.

Root causes of mysql error 3117 in your database

MySQL tracks replication steps using global transaction identifiers, which we call GTIDs. Each transaction must map to one clear identifier in the binary log. Some SQL statements break this rule because they cannot roll back as one unit. When you turn on the GTID consistency check, MySQL scans all current sessions. If an active session runs a restricted query, the engine raises error 3117.

Three main query patterns trigger this consistency warning during live traffic. First, an app might create a table using a select statement in one step. Second, a session might mix transactional tables and non-transactional tables in one block. Third, a script might create or drop temporary tables inside an open transaction. All three patterns make it impossible for replicas to replay logs without drift.

The official symbol for this warning is ER_ENFORCE_GTID_CONSISTENCY_WARN_WITH_ONGOING_GTID_VIOLATING_TX in the server logs. It tells you that the server detected incompatible work during a mode change. You do not need to restart the database to clear the state. You only need to find and finish the sessions that hold those open transactions.

How to diagnose and fix the failure in production

Start your check by looking at the active process list on the primary database. Look for long-running sessions that keeps the session active while your team applies server changes. Check the server error log to see which specific queries trigger the consistency warnings. The log shows the exact thread and statement type that blocks your mode change.

Do not grant broad admin roles to developers just to debug this issue. Instead, let a senior operator or automated tool read the performance tables with read-only rights. Once you spot the app that sends incompatible queries, pause that job for a moment. Wait a few seconds for all open transactions from that app to commit or roll back.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

After the active transactions finish, update the GTID consistency setting to the warning mode first. Let the database run in warning mode for a few days during peak traffic. Watch the logs to catch any rare batch jobs that still use temporary tables inside transactions. Ask the app team to split table creation and data insertion into two separate steps. Ask them to move temporary table statements outside of explicit transaction blocks.

Preventing GTID violations during daily operations

Once your logs stay clean for a full business cycle, switch the GTID rule to strict mode. Strict mode blocks any new query that tries to break replication safety rules. This protects your cluster from silent data drift when an engineer runs an ad-hoc script.

You should also review how engineers run manual queries against production databases. Manual scripts often use temporary tables or mix storage engines by mistake. Put a query review step in place so operators catch bad syntax before execution. You can also set up data masking to rewrite emails and phone numbers in query results. This keeps sensitive user records safe while your team inspects live replication tables.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

What does SQLSTATE HY000 mean for error 3117?

SQLSTATE HY000 is a general code that MySQL uses for server-specific warnings and errors. You must look at the error number 3117 to know that ongoing transactions violate GTID rules.

Can I ignore error 3117 if Ionly enable the warning mode?

You should not ignore it if you plan to turn on GTID replication later. Those active query patterns will fail hard once you switch the server to strict enforcement mode.

How do I stop temporary tables from causing GTID errors?

Make sure your app creates and drops temporary tables outside of open transaction blocks. Run those statements when autocommit is on so each action stays separate in the log.

The query runs. The emails stay hidden.