1# Include file running tests for a specified 2# restart type 3# 4--echo ndb_fully_replicated_restart2.inc ($restart_type) 5 6--echo Create FR table 7use test; 8create table test.t1 ( 9 a int primary key, 10 b int, 11 c int, 12 d int, 13 unique(c), key(d)) 14 comment="NDB_TABLE=FULLY_REPLICATED=1" engine=ndb; 15 16--echo Put some stuff into it 17--disable_query_log 18--disable_result_log 19--let $id=5120 20while ($id) 21{ 22 --eval insert into test.t1 values ($id,$id+1,$id+2,$id+3) 23 --dec $id 24} 25--enable_result_log 26--enable_query_log 27 28 29--echo ************************* 30--echo Pre-restart checks 31--echo ************************* 32 33--echo Check row count 34select @row_count:=count(1) from test.t1; 35 36--echo Show physical rows per logical row (NoOfReplicas * NumNodeGroups) 37select @prpr:=floor(sum(fixed_elem_count) / @row_count) as phys_rows_per_row 38 from ndbinfo.memory_per_fragment 39 where fq_name='test/def/t1'; 40 41# Run checks on behaviour of FR table 42--source ndb_fully_replicated_restart2_checks.inc 43 44 45# Now perform a restart as specified by the caller 46 47if ($restart_type == 'SR') 48{ 49 --echo Now perform a system restart 50 51 --exec $NDB_MGM --no-defaults --verbose=0 --execute "all restart" >> $NDB_TOOLS_OUTPUT 52 53 --echo Wait for SR to complete 54 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 55} 56 57if ($restart_type == 'NR') 58{ 59 --echo Now perform a rolling restart 60 # RR is more interesting than a single NR as it restarts every node, so any 61 # required runtime state must be correctly rebuilt 62 63 --echo Node 1 64 --exec $NDB_MGM --no-defaults --verbose=0 --execute "1 restart" >> $NDB_TOOLS_OUTPUT 65 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 66 67 --echo Node 2 68 --exec $NDB_MGM --no-defaults --verbose=0 --execute "2 restart" >> $NDB_TOOLS_OUTPUT 69 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 70 71 --echo Node 3 72 --exec $NDB_MGM --no-defaults --verbose=0 --execute "3 restart" >> $NDB_TOOLS_OUTPUT 73 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 74 75 --echo Node 4 76 --exec $NDB_MGM --no-defaults --verbose=0 --execute "4 restart" >> $NDB_TOOLS_OUTPUT 77 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 78} 79 80if ($restart_type == 'SRTO') 81{ 82 --echo Now perform SR with takeover 83 84 --echo Node 1 restart -n 85 --exec $NDB_MGM --no-defaults --verbose=0 --execute "1 restart -n" >> $NDB_TOOLS_OUTPUT 86 --echo Wait for Node 1 to enter NOSTART state 87 --exec $NDB_WAITER --no-defaults --not-started --wait-nodes=1 --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 88 89 --echo Now make some change and trigger some LCP action 90 # Potentially improve this to ensure LCPs complete 91 --exec $NDB_MGM --no-defaults --verbose=0 --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT 92 --sleep 10 93 --exec $NDB_MGM --no-defaults --verbose=0 --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT 94 --sleep 10 95 --exec $NDB_MGM --no-defaults --verbose=0 --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT 96 --sleep 10 97 98 --echo Now bring down the other nodes 99 --exec $NDB_MGM --no-defaults --verbose=0 --execute "ALL restart -n" >> $NDB_TOOLS_OUTPUT 100 101 --echo Wait for them to come down 102 --exec $NDB_WAITER --no-defaults --not-started --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 103 104 --echo Now start-em up 105 --exec $NDB_MGM --no-defaults --verbose=0 --execute "all start" >> $NDB_TOOLS_OUTPUT 106 107 --echo Wait for SR to complete 108 --exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" >> $NDB_TOOLS_OUTPUT 109} 110 111 112--echo --- Wait to establish connection 113--source include/ndb_not_readonly.inc 114 115 116--echo ************************** 117--echo Post-restart checks 118--echo ************************** 119 120 121# Run checks on behaviour of FR table 122--source ndb_fully_replicated_restart2_checks.inc 123 124 125--echo Delete the lot 126delete from test.t1 limit 1024; 127delete from test.t1 limit 1024; 128delete from test.t1 limit 1024; 129delete from test.t1 limit 1024; 130delete from test.t1 limit 1024; 131delete from test.t1 limit 1024; 132 133select @new_row_count:=count(1) from test.t1; 134 135select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1'; 136 137#--echo Show fragment balance 138#select avg(fixed_elem_count), std(fixed_elem_count), min(fixed_elem_count), max(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1'; 139 140--echo Check new Physical row count against expected 141select floor(@new_row_count * @prpr) as expected_phys_rows, 142 sum(fixed_elem_count) as actual_phys_rows, 143 @diff:=(@new_row_count * @prpr) - sum(fixed_elem_count) as diff 144 from ndbinfo.memory_per_fragment 145 where fq_name='test/def/t1'; 146 147--let $d=query_get_value(select @diff as d, d, 1) 148 149if ($d) 150{ 151 --echo Show actual fragments 152 select * from ndbinfo.memory_per_fragment 153 where fq_name='test/def/t1' 154 order by 155 node_id, fragment_num; 156 --die Physical vs Logical row count error 157} 158 159--echo Check UI physical row count against expected 160select floor(@new_row_count * @prpr) as expected_phys_rows, 161 sum(fixed_elem_count) as actual_phys_rows, 162 @diff:=(@new_row_count * @prpr) - sum(fixed_elem_count) as diff 163 from ndbinfo.memory_per_fragment 164 where parent_fq_name='test/def/t1' and fq_name like '%/c$unique'; 165 166drop table test.t1; 167