Skip to content

Commit 88d43af

Browse files
hemantdangi-gcsysprg
authored andcommitted
MDEV-37366: Inconsistency detected - create sequence
Issue: When applying 'SELECT NEXT VALUE..' on applier node with binlog_row_image=MINIMAL and log-binlog enabled, applier node fails with below error: Slave SQL: Could not execute Write_rows_v1 event on table monitor.seq_moni_num; Unknown error, Error_code: 1105; handler error No Error!; the event's master log FIRST, end_log_pos 0, Internal MariaDB error code: 1105 To reproduce run below command on the first/active node: > CREATE SEQUENCE `seq_test` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=InnoDB; > SELECT NEXT VALUE FOR seq_test; > SELECT NEXT VALUE FOR seq_test; The applier node will leave the cluster after executing the 'SELECT NEXT VALUE' with below error: ERROR] Slave SQL: Could not execute Write_rows_v1 event on table test.seq_test; Unknown error, Error_code: 1105; handler error No Error!; the event's master log FIRST, end_log_pos 0, Internal MariaDB error code: 1105 [Warning] WSREP: Event 3 Write_rows_v1 apply failed: 195, seqno 14511334511 Solution: When binary loggging is enabled and binlog_row_image is set to 'MINIMAL', then 'SELECT NEXT VALUE' fails to apply on applier node. It fails with error HA_ERR_SEQUENCE_INVALID_DATA 195 in sequence_definition::check_and_adjust() because sequence variables like min_value, max_value, start are 0. The marking of all columns in 'TABLE::mark_columns_per_binlog_row_image()' will prevent update/set column values for the sequence table. For the sequence table column bitmap sent from master is only used. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent 858dc5b commit 88d43af

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
connection node_2;
2+
connection node_1;
3+
connection node_1;
4+
connection node_2;
5+
connection node_1;
6+
SET SESSION binlog_row_image=minimal;
7+
CREATE SEQUENCE `seq_test` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=InnoDB;
8+
SHOW CREATE TABLE seq_test;
9+
Table Create Table
10+
seq_test CREATE TABLE `seq_test` (
11+
`next_not_cached_value` bigint(21) NOT NULL,
12+
`minimum_value` bigint(21) NOT NULL,
13+
`maximum_value` bigint(21) NOT NULL,
14+
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
15+
`increment` bigint(21) NOT NULL COMMENT 'increment value',
16+
`cache_size` bigint(21) unsigned NOT NULL,
17+
`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',
18+
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
19+
) ENGINE=InnoDB SEQUENCE=1
20+
SELECT NEXT VALUE FOR seq_test;
21+
NEXT VALUE FOR seq_test
22+
1
23+
SELECT NEXT VALUE FOR seq_test;
24+
NEXT VALUE FOR seq_test
25+
3
26+
connection node_2;
27+
DROP SEQUENCE seq_test;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# MDEV-37366: Inconsistency detected - create sequence
3+
# Failed 'SELECT NEXT VALUE' on applier node.
4+
#
5+
--source include/galera_cluster.inc
6+
--source include/have_innodb.inc
7+
--source include/big_test.inc
8+
--source include/have_log_bin.inc
9+
10+
#
11+
# Save original auto_increment_offset values.
12+
#
13+
--let $node_1=node_1
14+
--let $node_2=node_2
15+
--source ../galera/include/auto_increment_offset_save.inc
16+
17+
#
18+
# Verify there are two nodes in galera cluster.
19+
#
20+
--connection node_1
21+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
22+
--source include/wait_condition.inc
23+
24+
#
25+
# Create a sequence table on node1.
26+
#
27+
SET SESSION binlog_row_image=minimal;
28+
CREATE SEQUENCE `seq_test` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=InnoDB;
29+
SHOW CREATE TABLE seq_test;
30+
31+
#
32+
# Execute 'SELECT NEXT VALUE' which should not fail on applier node.
33+
#
34+
SELECT NEXT VALUE FOR seq_test;
35+
SELECT NEXT VALUE FOR seq_test;
36+
37+
#
38+
# Verify there are two nodes in galera cluster.
39+
#
40+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
41+
--source include/wait_condition.inc
42+
43+
#
44+
# Cleanup
45+
#
46+
--connection node_2
47+
48+
DROP SEQUENCE seq_test;
49+
50+
# Restore original variable values.
51+
--source ../galera/include/auto_increment_offset_restore.inc

sql/table.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7952,6 +7952,19 @@ void TABLE::mark_columns_per_binlog_row_image()
79527952
if (file->row_logging &&
79537953
!ha_check_storage_engine_flag(s->db_type(), HTON_NO_BINLOG_ROW_OPT))
79547954
{
7955+
#ifdef WITH_WSREP
7956+
/**
7957+
The marking of all columns will prevent update/set column values for the
7958+
sequence table. For the sequence table column bitmap sent from master is
7959+
used.
7960+
*/
7961+
if (WSREP(thd) && wsrep_thd_is_applying(thd) &&
7962+
s->sequence && s->primary_key >= MAX_KEY)
7963+
{
7964+
DBUG_VOID_RETURN;
7965+
}
7966+
#endif /* WITH_WSREP */
7967+
79557968
/* if there is no PK, then mark all columns for the BI. */
79567969
if (s->primary_key >= MAX_KEY)
79577970
{

0 commit comments

Comments
 (0)