Common SQL Errors

MySQL Error 3116 ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS: How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL blocks turning ENFORCE_GTID_CONSISTENCY to ON because at least one open transaction contains statements that violate GTID rules.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is error code 3116 ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS?

MySQL error 3116 ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS occurs when you enable ENFORCE_GTID_CONSISTENCY while unsafe transactions are still open. Finish, rollback, or kill those sessions, then re-run SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON to resolve the issue.

Error Highlights

Typical Error Message

ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS

Error Type

Replication Configuration Error

Language

MySQL

Symbol

are ongoing transactions that violate GTID consistency. ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS is renamed to ER_CANT_ENFORCE_GTID_CONSISTENCY_WITH_ONGOING_GTID_VIOLATING_TX in MySQL 8.0. ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS was added in 5.7.6.

Error Code

3116

SQL State

HY000

Explanation

Table of Contents

What is error code 3116 ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS?

MySQL raises error 3116 when you try to change ENFORCE_GTID_CONSISTENCY from OFF to ON while at least one open transaction already executed statements that break GTID safety rules such as CREATE TEMPORARY TABLE or implicit XA operations.

The server refuses the request to protect replication integrity because GTID based replication needs every transaction to be deterministic and replayable on replicas.

What Causes This Error?

Unfinished sessions that include unsafe statements violate GTID rules, so MySQL blocks the variable change until those transactions are closed.

Long running autocommit=0 workloads, interactive shells left inside transactions, or bulk loads that create temporary objects commonly trigger the problem.

How to Fix ER_CANT_SET_ENFORCE_GTID_CONSISTENCY_ON_WITH_ONGOING_GTID_VIOLATING_TRANSACTIONS

Identify offending sessions with SHOW PROCESSLIST, then COMMIT, ROLLBACK, or KILL each connection. Afterwards execute SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; the command should now succeed.

If you require a rolling switch, place the server in read only mode, wait for existing writes to drain, verify no violating transactions remain, and finally enable enforcement.

Common Scenarios and Solutions

Idle client consoles often keep transactions open. Simply issue COMMIT or exit the client to clear the lock and retry.

ETL jobs that use CREATE TEMPORARY TABLE cause violations. Rewrite the job to use normal tables or run it after GTID enforcement has been enabled.

Best Practices to Avoid This Error

Schedule GTID transitions during planned maintenance, set READ_ONLY=ON, and ensure applications disconnect before toggling ENFORCE_GTID_CONSISTENCY.

Adopt code reviews or Galaxy query endorsements to block unsafe statements early and keep production always GTID safe.

Related Errors and Solutions

Error 1780 ER_GTID_UNSAFE_DEFINITION signals an unsafe DDL inside a GTID transaction. Remove or rewrite the statement to comply with GTID rules.

Error 1782 ER_GTID_UNSAFE_CREATE_SELECT appears when CREATE TABLE ... SELECT runs in GTID mode. Use INSERT ... SELECT into an existing table or refactor the workflow.

Common Causes

Open multistatement transactions

START TRANSACTION sessions not yet committed or rolled back still hold unsafe statements.

Long running bulk loads

ETL tools that create temporary tables or non deterministic DDL block GTID enforcement until completion.

Interactive shells left idle

Developers sometimes forget to commit after making schema changes, leaving the session open indefinitely.

Autocommit disabled applications

Frameworks that set autocommit=0 start transactions automatically and may include unsafe DDL.

Related Errors

Error 1780 ER_GTID_UNSAFE_DEFINITION

Unsafe definition found during GTID mode. Resolve by rewriting or isolating the DDL.

Error 1782 ER_GTID_UNSAFE_CREATE_SELECT

CREATE TABLE ... SELECT detected as GTID unsafe. Replace with INSERT ... SELECT.

Error 3088 ER_CANT_SET_GTID_MODE_ON_WITH_GTID_MODE_OFF_SLAVES

Replica servers must already run GTID mode to switch the source to ON.

FAQs

How do I locate GTID violating transactions quickly?

Run SHOW PROCESSLIST or PERFORMANCE_SCHEMA tables to see sessions executing CREATE TEMPORARY TABLE or other unsafe operations, then act on those session IDs.

Will killing sessions cause data loss?

Use COMMIT or ROLLBACK first. If you must KILL the session, uncommitted changes are rolled back, preserving consistency but discarding pending work.

Can I force ENFORCE_GTID_CONSISTENCY without closing transactions?

No. MySQL intentionally blocks the change to protect replication. All offending transactions must end before the variable can be set to ON.

How does Galaxy help avoid this error?

Galaxy highlights unsafe statements during query review and lets teams endorse GTID safe queries, reducing the chance of violating transactions reaching production.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo