~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb_binlog/t/ndb_binlog_unique_epoch.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--source include/have_ndb.inc
 
2
--source include/have_log_bin.inc
 
3
--source include/have_debug.inc
 
4
 
 
5
# Bug#35217 Strange ndb_binlog_index error inserting rows in MyISAM table
 
6
# Verify that mysql.ndb_binlog_index is getting unique epoch values
 
7
# Do this by dropping the PK, inserting some data and checking
 
8
# uniqueness
 
9
 
10
alter table mysql.ndb_binlog_index drop primary key;
 
11
 
 
12
use test;
 
13
 
 
14
create table t1 (a int) engine=ndb;
 
15
 
 
16
delimiter %;
 
17
create procedure ins (rows int)
 
18
begin
 
19
  set @x = 0;
 
20
  repeat
 
21
    insert into t1 values (1);
 
22
    set @x = @x + 1;
 
23
  until @x = rows
 
24
  end repeat;
 
25
end%
 
26
 
 
27
delimiter ;%
 
28
 
 
29
call ins(10000);
 
30
 
 
31
# Did any of the epochs have > 1 entry?
 
32
# (Answer should be no !)
 
33
--echo Duplicate epochs according to mysql.ndb_binlog_index
 
34
select epoch >> 32 as gci, 
 
35
       (epoch << 32) >> 32 as ugci, 
 
36
       sum(1) as count 
 
37
from mysql.ndb_binlog_index 
 
38
group by epoch 
 
39
having count > 1;
 
40
 
 
41
# Now look at what's in the Binlog events themselves, in case they also
 
42
# carry duplicate epochs
 
43
#
 
44
# Code here similar to ndb_binlog_get_binlog_stmts.inc
 
45
#
 
46
--disable_query_log
 
47
let $MYSQLD_DATADIR= `select @@datadir;`;
 
48
--exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/mysqld-bin.000001 > $MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql
 
49
 
 
50
create table raw_binlog_rows (txt varchar(1000));
 
51
 
 
52
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql' into table raw_binlog_rows columns terminated by '\n';
 
53
 
 
54
create table binlog_stmt_parts_unassoc (txt varchar(1000), line_count int, stmt_boundary int);
 
55
 
 
56
set @line_count=0;
 
57
set @stmt_boundary=0;
 
58
 
 
59
# Use replace() here to get rid of any unwanted Windows
 
60
# CRs
 
61
insert into binlog_stmt_parts_unassoc
 
62
  select replace(txt, '\r', ''),
 
63
         @line_count:= @line_count + 1,  # So we can preserve order later
 
64
         (txt like '%INSERT%' or         # Identify statement boundaries
 
65
          txt like '%UPDATE%' or
 
66
          txt like '%DELETE%')
 
67
    from raw_binlog_rows
 
68
    where
 
69
      txt like '###%';                   # Discard non verbose output
 
70
 
 
71
create table binlog_stmt_parts_assoc (txt varchar(1000), line_count int, stmt_num int);
 
72
 
 
73
set @stmt_count = 0;
 
74
 
 
75
insert into binlog_stmt_parts_assoc
 
76
  select txt, 
 
77
         line_count, 
 
78
         @stmt_count:= @stmt_count + stmt_boundary   # All rows from same stmt will
 
79
                                                     # have same stmt_num
 
80
    from binlog_stmt_parts_unassoc order by line_count;
 
81
 
 
82
create table binlog_stmts (txt varchar(1000), stmt_num int);
 
83
 
 
84
insert into binlog_stmts 
 
85
  select group_concat(right(txt,             # Combine rows in statment into 1
 
86
                            length(txt) - 4) # Trim ### from line start
 
87
                      order by line_count
 
88
                      separator ' '), stmt_num
 
89
    from binlog_stmt_parts_assoc
 
90
    group by stmt_num;
 
91
 
 
92
 
 
93
create table epochs_in_binlog (epoch bigint);
 
94
 
 
95
# Trim INSERT INTO mysql.ndb_apply_status SET   @1=1   @2=144115213845659648   @3=''   @4=0   @5=0
 
96
# down to a list of epochs
 
97
#
 
98
insert into epochs_in_binlog
 
99
  select substring_index(right(txt, length(txt) - instr(txt, '@2=') - 3),' ', 1) 
 
100
         from binlog_stmts
 
101
         where txt like '%ndb_apply_status%' 
 
102
         order by txt;
 
103
 
 
104
--enable_query_log
 
105
--echo Duplicate epochs according to MySQLD Binlog entries
 
106
select  epoch >> 32 as gci, 
 
107
       (epoch << 32) >> 32 as ugci, 
 
108
       sum(1) as count 
 
109
from epochs_in_binlog
 
110
group by epoch
 
111
having count > 1;
 
112
 
 
113
--disable_query_log
 
114
drop table raw_binlog_rows;
 
115
drop table binlog_stmt_parts_unassoc;
 
116
drop table binlog_stmt_parts_assoc;
 
117
drop table binlog_stmts;
 
118
drop table epochs_in_binlog;
 
119
--enable_query_log
 
120
 
 
121
# Now cleanup
 
122
 
 
123
reset master;
 
124
alter table mysql.ndb_binlog_index add primary key (epoch, orig_server_id, orig_epoch);
 
125
 
 
126
drop procedure ins;
 
127
drop table t1;