diff --git a/mysql-test/suite/binlog/r/binlog_gtid_exhausted.result b/mysql-test/suite/binlog/r/binlog_gtid_exhausted.result new file mode 100644 index 0000000..85b2704 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_gtid_exhausted.result @@ -0,0 +1,16 @@ +# +# Ensure transaction is rolled back on failure to generate a GTID +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +RESET MASTER; +SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805'); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +ERROR HY000: Impossible to generate Global Transaction Identifier: the integer component reached the maximal value. Restart the server with a new server_uuid. +SELECT * FROM t1; +a +1 +RESET MASTER; +SET GLOBAL gtid_purged = ''; +DROP TABLE t1; +RESET MASTER; diff --git a/mysql-test/suite/binlog/t/binlog_gtid_exhausted.test b/mysql-test/suite/binlog/t/binlog_gtid_exhausted.test new file mode 100644 index 0000000..055c848 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_gtid_exhausted.test @@ -0,0 +1,19 @@ +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/have_gtid.inc + +--echo # +--echo # Ensure transaction is rolled back on failure to generate a GTID +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +RESET MASTER; +SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805'); +INSERT INTO t1 VALUES (1); +--error ER_GNO_EXHAUSTED +INSERT INTO t1 VALUES (2); +SELECT * FROM t1; +RESET MASTER; +SET GLOBAL gtid_purged = ''; +DROP TABLE t1; +RESET MASTER; diff --git a/sql/binlog.cc b/sql/binlog.cc index a02b987..c0e127c 100644 --- a/sql/binlog.cc +++ b/sql/binlog.cc @@ -1212,6 +1212,8 @@ binlog_cache_data::flush(THD *thd, my_off_t *bytes_written, bool *wrote_xid) */ if (!(error= gtid_before_write_cache(thd, this))) error= mysql_bin_log.write_cache(thd, this); + else + thd->commit_error= THD::CE_FLUSH_ERROR; if (flags.with_xid && error == 0) *wrote_xid= true;