File: ndb_binlog_unique_epoch.test

package info (click to toggle)
percona-xtrabackup 2.2.3-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 293,260 kB
  • ctags: 146,881
  • sloc: cpp: 1,051,960; ansic: 570,217; java: 54,595; perl: 53,495; pascal: 44,194; sh: 27,826; yacc: 15,314; python: 12,142; xml: 7,848; sql: 4,125; makefile: 1,459; awk: 785; lex: 758
file content (127 lines) | stat: -rw-r--r-- 3,747 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--source include/have_ndb.inc
--source include/have_log_bin.inc
--source include/have_debug.inc

# Bug#35217 Strange ndb_binlog_index error inserting rows in MyISAM table
# Verify that mysql.ndb_binlog_index is getting unique epoch values
# Do this by dropping the PK, inserting some data and checking
# uniqueness
# 
alter table mysql.ndb_binlog_index drop primary key;

use test;

create table t1 (a int) engine=ndb;

delimiter %;
create procedure ins (rows int)
begin
  set @x = 0;
  repeat
    insert into t1 values (1);
    set @x = @x + 1;
  until @x = rows
  end repeat;
end%

delimiter ;%

call ins(10000);

# Did any of the epochs have > 1 entry?
# (Answer should be no !)
--echo Duplicate epochs according to mysql.ndb_binlog_index
select epoch >> 32 as gci, 
       (epoch << 32) >> 32 as ugci, 
       sum(1) as count 
from mysql.ndb_binlog_index 
group by epoch 
having count > 1;

# Now look at what's in the Binlog events themselves, in case they also
# carry duplicate epochs
#
# Code here similar to ndb_binlog_get_binlog_stmts.inc
#
--disable_query_log
let $MYSQLD_DATADIR= `select @@datadir;`;
--exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/mysqld-bin.000001 > $MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql

create table raw_binlog_rows (txt varchar(1000));

--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql' into table raw_binlog_rows columns terminated by '\n';

create table binlog_stmt_parts_unassoc (txt varchar(1000), line_count int, stmt_boundary int);

set @line_count=0;
set @stmt_boundary=0;

# Use replace() here to get rid of any unwanted Windows
# CRs
insert into binlog_stmt_parts_unassoc
  select replace(txt, '\r', ''),
         @line_count:= @line_count + 1,  # So we can preserve order later
         (txt like '%INSERT%' or         # Identify statement boundaries
          txt like '%UPDATE%' or
          txt like '%DELETE%')
    from raw_binlog_rows
    where
      txt like '###%';                   # Discard non verbose output

create table binlog_stmt_parts_assoc (txt varchar(1000), line_count int, stmt_num int);

set @stmt_count = 0;

insert into binlog_stmt_parts_assoc
  select txt, 
         line_count, 
         @stmt_count:= @stmt_count + stmt_boundary   # All rows from same stmt will
                                                     # have same stmt_num
    from binlog_stmt_parts_unassoc order by line_count;

create table binlog_stmts (txt varchar(1000), stmt_num int);

insert into binlog_stmts 
  select group_concat(right(txt,             # Combine rows in statment into 1
                            length(txt) - 4) # Trim ### from line start
                      order by line_count
                      separator ' '), stmt_num
    from binlog_stmt_parts_assoc
    group by stmt_num;


create table epochs_in_binlog (epoch bigint);

# Trim INSERT INTO mysql.ndb_apply_status SET   @1=1   @2=144115213845659648   @3=''   @4=0   @5=0
# down to a list of epochs
#
insert into epochs_in_binlog
  select substring_index(right(txt, length(txt) - instr(txt, '@2=') - 3),' ', 1) 
         from binlog_stmts
         where txt like '%ndb_apply_status%' 
         order by txt;

--enable_query_log
--echo Duplicate epochs according to MySQLD Binlog entries
select  epoch >> 32 as gci, 
       (epoch << 32) >> 32 as ugci, 
       sum(1) as count 
from epochs_in_binlog
group by epoch
having count > 1;

--disable_query_log
drop table raw_binlog_rows;
drop table binlog_stmt_parts_unassoc;
drop table binlog_stmt_parts_assoc;
drop table binlog_stmts;
drop table epochs_in_binlog;
--enable_query_log

# Now cleanup

reset master;
alter table mysql.ndb_binlog_index add primary key (epoch, orig_server_id, orig_epoch);

drop procedure ins;
drop table t1;