diff --git a/mysql-test/suite/galera/r/MDEV-37366.result b/mysql-test/suite/galera/r/MDEV-37366.result new file mode 100644 index 00000000000..9fbd6be70f2 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-37366.result @@ -0,0 +1,27 @@ +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_1; +SET SESSION binlog_row_image=minimal; +CREATE SEQUENCE `seq_test` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=InnoDB; +SHOW CREATE TABLE seq_test; +Table Create Table +seq_test CREATE TABLE `seq_test` ( + `next_not_cached_value` bigint(21) NOT NULL, + `minimum_value` bigint(21) NOT NULL, + `maximum_value` bigint(21) NOT NULL, + `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', + `increment` bigint(21) NOT NULL COMMENT 'increment value', + `cache_size` bigint(21) unsigned NOT NULL, + `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed', + `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' +) ENGINE=InnoDB SEQUENCE=1 +SELECT NEXT VALUE FOR seq_test; +NEXT VALUE FOR seq_test +1 +SELECT NEXT VALUE FOR seq_test; +NEXT VALUE FOR seq_test +3 +connection node_2; +DROP SEQUENCE seq_test; diff --git a/mysql-test/suite/galera/t/MDEV-37366.test b/mysql-test/suite/galera/t/MDEV-37366.test new file mode 100644 index 00000000000..939f760308a --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-37366.test @@ -0,0 +1,51 @@ +# +# MDEV-37366: Inconsistency detected - create sequence +# Failed 'SELECT NEXT VALUE' on applier node. +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/big_test.inc +--source include/have_log_bin.inc + +# +# Save original auto_increment_offset values. +# +--let $node_1=node_1 +--let $node_2=node_2 +--source ../galera/include/auto_increment_offset_save.inc + +# +# Verify there are two nodes in galera cluster. +# +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# +# Create a sequence table on node1. +# +SET SESSION binlog_row_image=minimal; +CREATE SEQUENCE `seq_test` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=InnoDB; +SHOW CREATE TABLE seq_test; + +# +# Execute 'SELECT NEXT VALUE' which should not fail on applier node. +# +SELECT NEXT VALUE FOR seq_test; +SELECT NEXT VALUE FOR seq_test; + +# +# Verify there are two nodes in galera cluster. +# +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# +# Cleanup +# +--connection node_2 + +DROP SEQUENCE seq_test; + +# Restore original variable values. +--source ../galera/include/auto_increment_offset_restore.inc diff --git a/sql/table.cc b/sql/table.cc index 683da12f7d9..8cd9957b88c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7952,6 +7952,19 @@ void TABLE::mark_columns_per_binlog_row_image() if (file->row_logging && !ha_check_storage_engine_flag(s->db_type(), HTON_NO_BINLOG_ROW_OPT)) { +#ifdef WITH_WSREP + /** + The marking of all columns will prevent update/set column values for the + sequence table. For the sequence table column bitmap sent from master is + used. + */ + if (WSREP(thd) && wsrep_thd_is_applying(thd) && + s->sequence && s->primary_key >= MAX_KEY) + { + DBUG_VOID_RETURN; + } +#endif /* WITH_WSREP */ + /* if there is no PK, then mark all columns for the BI. */ if (s->primary_key >= MAX_KEY) {