Debian Codegraph @

mysql-test/suite/ndb/t/ndb_backup_log.test

raw
1 -- source include/have_ndb.inc
2 -- source include/have_ndb_debug.inc
3
4 -- source suite/ndb/include/backup_restore_setup.inc
5
6 --echo Check that backup contains the expected log entries
7
8 --echo Use a table with (almost) as big primary key as possible and also
9 --echo (almost) as big row as possible, aiming to catch row data buffer
10 --echo overflows in Ndb.
11 --echo One could stretch the Ndb internal row size even more by using as
12 --echo many columns in the primary key as possible, and also as many
13 --echo columns in for the row in total, but this simpler table is choosen
14 --echo to avoid cumbersome statements.
15
16 create table t1 (
17 a int,
18 av varbinary(3064) not null,
19 b int,
20 bv varbinary(26920) not null,
21 primary key(a,av)
22 ) engine=ndb;
23
24 --echo Add 100 rows
25 --disable_query_log
26 let $rows=100;
27 while ($rows)
28 {
29 eval insert into t1 values ($rows, repeat('A',3064), $rows, repeat('Z',26920));
30 dec $rows;
31 }
32 --enable_query_log
33
34 --echo Start a backup with completion stalled
35 --exec $NDB_MGM -e "all error 10039"
36 --echo Run backup
37 --source suite/ndb/t/ndb_backup_nowait_start.inc
38
39 --echo Make a set of changes which we expect to be logged
40
41 --echo 5 new rows
42 insert into t1 values
43 (101, repeat('B', 3064), 101, repeat('M', 26920)),
44 (102, repeat('C', 3064), 102, repeat('N', 26920)),
45 (103, repeat('D', 3064), 103, repeat('O', 26920)),
46 (104, repeat('E', 3064), 104, repeat('P', 26920)),
47 (105, repeat('F', 3064), 105, repeat('Q', 26920));
48
49 --echo 10 rows updated
50 update t1 set b=b+1, bv=repeat('R', 10920) where a >= 50 and a < 60;
51
52 --echo 5 rows deleted
53 delete from t1 order by a limit 5;
54
55 --echo 5 new rows updated
56 update t1 set b=b*2, bv=repeat('S', 10920) where a>100 and av <> repeat('_', 3064);
57
58 --echo 5 new rows deleted
59 delete from t1 where a > 100;
60
61
62 --echo Allow backup to complete...
63 --exec $NDB_MGM -e "all error 0"
64
65 --source suite/ndb/t/ndb_backup_nowait_wait.inc
66
67 truncate t1;
68
69 --echo Now restore it and check the log content
70 --let $outfile = $MYSQLTEST_VARDIR/tmp/ndb_backup_log.txt
71 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --print-log $NDB_BACKUPS-$the_backup_id > $outfile 2>&1
72 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --print-log $NDB_BACKUPS-$the_backup_id >> $outfile 2>&1
73
74 drop table t1;
75
76 create table txt (a varbinary(36000));
77
78 --disable_query_log
79 eval load data infile '$outfile' into table txt fields terminated by '\r';
80 --enable_query_log
81
82 --remove_file $outfile
83
84 create table logentries as
85 select * from txt where
86 (a like 'INSERT %') or
87 (a like 'UPDATE %') or
88 (a like 'DELETE %');
89
90 --echo Count of log entries
91 select count(1) from logentries;
92
93 --echo Show logentries
94 --echo Note, column values are truncated to near 1000 bytes due to use of NdbOut.
95 select * from logentries order by a;
96
97 --echo Show no duplicates
98 select a, count(1) from logentries group by a having (count(1) > 1);
99
100 drop table logentries;
101 drop table txt;
102
103
104 --source suite/ndb/include/backup_restore_cleanup.inc