The server refuses WAIT_FOR_EXECUTED_GTID_SET because the current session already owns the specified GTID.
MySQL error 3173 ER_CANT_WAIT_FOR_EXECUTED_GTID_SET_WHILE_OWNING_A_GTID occurs when a session calls WAIT_FOR_EXECUTED_GTID_SET on a GTID it already owns. Release or commit the transaction, or use a different GTID, to resolve the replication wait failure.
ER_CANT_WAIT_FOR_EXECUTED_GTID_SET_WHILE_OWNING_A_GTID
Error 3173 is raised when a session invokes the function WAIT_FOR_EXECUTED_GTID_SET for a GTID that the same session already owns through an uncommitted transaction. MySQL refuses to wait because the request would block on itself.
The error was introduced in MySQL 5.7.9 as part of enhanced GTID replication safeguards. It surfaces primarily in high-availability setups that rely on GTID-based replication monitoring.
The error appears during replication health checks, failover scripts, or custom tooling that calls WAIT_FOR_EXECUTED_GTID_SET right after starting a transaction that has not yet been committed or rolled back.
It can also show up in interactive sessions where developers manually run WAIT_FOR_EXECUTED_GTID_SET while holding open transactions.
Ignoring the error leaves scripts hanging or in retry loops, delaying replication lag detection and automatic failover. Fast remediation ensures predictable automation and maintains cluster availability.
The primary trigger is an uncommitted transaction that acquired a GTID. MySQL marks that GTID as owned by the session until commit or rollback. A subsequent WAIT_FOR_EXECUTED_GTID_SET call on the same GTID hits a self-dependency and raises error 3173.
It also occurs if a stored procedure starts a transaction, then invokes WAIT_FOR_EXECUTED_GTID_SET before completing the transaction.
Commit or rollback the current transaction to release the GTID. After the GTID is released, reissue WAIT_FOR_EXECUTED_GTID_SET.
If the wait is required inside the same script, split the logic: finish the write, close the session, open a new connection, and call WAIT_FOR_EXECUTED_GTID_SET from the fresh session.
In automation frameworks, wrap the write phase and the wait phase in separate connections. This removes ownership conflicts.
When using pt-online-schema-change or custom DDL tools, disable WAIT_FOR_EXECUTED_GTID_SET or ensure every migration completes COMMIT before checking GTID execution.
Always commit or rollback quickly in GTID environments. Long-running transactions dramatically increase the chance of ownership collisions.
In Galaxy, developers can enable auto-commit or use the editor's transaction snippets to guarantee commits before issuing replication checks, preventing error 3173.
Error 3170 ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE arises when GTID mode meets non-transactional tables. Convert MyISAM tables to InnoDB to resolve it.
Error 3171 ER_GTID_UNSAFE_CREATE_SELECT stems from CREATE TABLE ... SELECT in GTID mode. Wrap the statement in a transaction or disable GTID for that session.
The session starts a transaction that generates a new GTID but does not commit before calling WAIT_FOR_EXECUTED_GTID_SET.
A procedure issues DML, then incorrectly checks replication progress without first committing.
Failover or backup tools perform writes and waits on the same persistent connection, causing self-dependency.
Raised when attempting GTID writes to non-transactional tables. Convert tables to InnoDB.
Occurs on CREATE TABLE ... SELECT statements under GTID enforcement. Wrap the operation in a single transaction.
Appears during GTID purging when the supplied set conflicts with executed GTIDs.
No. GTID mode offers strong replication guarantees. Fix the script logic to commit before waiting instead of disabling GTIDs.
Ignoring it may leave automation out of sync. Always handle the error and retry after committing or using another session.
Yes. With autocommit on, each statement commits immediately, releasing GTID ownership before any WAIT_FOR_EXECUTED_GTID_SET call.
Galaxy highlights uncommitted transactions and lets you run waits in a new tab, ensuring sessions never conflict over GTID ownership.