6 The tunable RecoverPDBBySeqNum controls how we perform recovery
7 on persistent databases.
8 The default is that persistent databases are recovered exactly the same
9 way as normal databases. That is that we recover record by record.
11 If RecoverPDBBySeqNum is set to 1 AND if a record with the key
12 "__db_sequence_number__" can be found in the database, then instead we will
13 perform the recovery by picking the copy of the database from the node
14 that has the highest sequence number and ignore the content on all other
20 * An active CTDB cluster with at least 2 active nodes.
24 1. Verify that the status on all of the ctdb nodes is 'OK'.
25 2. create a persistent test database
26 3. test that RecoveryPDBBySeqNum==0 and no seqnum record blends the database
28 4. test that RecoveryPDBBySeqNum==0 and seqnum record blends the database
30 5. test that RecoveryPDBBySeqNum==1 and no seqnum record blends the database
32 6. test that RecoveryPDBBySeqNum==1 and seqnum record does not blend the database
37 * that 3,4,5 will blend the databases and that 6 will recovery the highest seqnum
43 .
"${TEST_SCRIPTS_DIR}/integration.bash"
52 ctdb_restart_when_done
54 try_command_on_node
0 "$CTDB listnodes"
55 num_nodes
=$
(echo "$out" |
wc -l)
57 add_record_per_node
()
60 while [ $_i -lt $num_nodes ] ; do
63 echo "Store key(${_k}) data(${_d}) on node ${_i}"
64 db_ctdb_tstore
$_i "$test_db" "$_k" "$_d"
69 test_db
="persistent_test.tdb"
70 echo "Create persistent test database \"$test_db\""
71 try_command_on_node
0 $CTDB attach
"$test_db" persistent
74 echo "Setting RecoverPDBBySeqNum=0"
75 try_command_on_node all
$CTDB setvar
"RecoverPDBBySeqNum" 0
78 # If RecoverPDBBySeqNum==0 and no __db_sequence_number__
79 # recover record by record
83 echo "Test that RecoverPDBBySeqNum=0 and no __db_sequence_number__ blends the database during recovery"
85 echo "Wipe test database"
86 try_command_on_node
0 $CTDB wipedb
"$test_db"
91 echo "Force a recovery"
92 try_command_on_node
0 $CTDB recover
94 # check that we now have both records on node 0
95 num_records
=$
(db_ctdb_cattdb_count_records
0 "$test_db")
96 if [ $num_records = "$num_nodes" ] ; then
97 echo "OK: databases were blended"
99 echo "BAD: we did not end up with the expected $num_nodes records after the recovery"
104 # If RecoverPDBBySeqNum==0 and __db_sequence_number__
105 # recover record by record
109 echo "Test that RecoverPDBBySeqNum=0 and __db_sequence_number__ blends the database during recovery"
111 echo "Wipe the test database"
112 try_command_on_node
0 $CTDB wipedb persistent_test.tdb
116 echo "Add __db_sequence_number__==5 record to all nodes"
118 while [ $pnn -lt $num_nodes ] ; do
119 db_ctdb_tstore_dbseqnum
$pnn "$test_db" 5
123 echo "Set __db_sequence_number__ to 7 on node 0"
124 db_ctdb_tstore_dbseqnum
0 "$test_db" 7
126 echo "Set __db_sequence_number__ to 8 on node 1"
127 db_ctdb_tstore_dbseqnum
1 "$test_db" 8
130 echo "Force a recovery"
131 try_command_on_node
0 $CTDB recover
133 # check that we now have both records on node 0
134 num_records
=$
(db_ctdb_cattdb_count_records
0 "$test_db")
135 if [ $num_records = "$num_nodes" ] ; then
136 echo "OK: databases were blended"
138 echo "BAD: we did not end up with the expected $num_nodes records after the recovery"
139 try_command_on_node
-v 0 $CTDB cattdb
"$test_db"
144 # set RecoverPDBBySeqNum=1
146 echo "Setting RecoverPDBBySeqNum to 1"
147 try_command_on_node all
$CTDB setvar
"RecoverPDBBySeqNum" 1
151 # If RecoverPDBBySeqNum==1 and no __db_sequence_number__
152 # recover whole database
156 echo "Test that RecoverPDBBySeqNum=1 and no __db_sequence_number__ does not blend the database during recovery"
157 echo "Wipe the test database"
158 try_command_on_node
0 $CTDB wipedb
"$test_db"
163 echo force a recovery
164 try_command_on_node
0 $CTDB recover
166 # Check that we now have 1 record on node 0
167 num_records
=$
(db_ctdb_cattdb_count_records
0 "$test_db")
168 if [ $num_records = "1" ] ; then
169 echo "OK: databases were not blended"
171 echo "BAD: we did not end up with the expected single record after the recovery"
178 # If RecoverPDBBySeqNum==1 and __db_sequence_number__
179 # recover whole database
183 echo test that RecoverPDBBySeqNum
==1 and __db_sequence_number__ does not blend the database during recovery
184 echo wipe the
test database
185 try_command_on_node
0 $CTDB wipedb persistent_test.tdb
189 echo "Add __db_sequence_number__==5 record to all nodes"
191 while [ $pnn -lt $num_nodes ] ; do
192 db_ctdb_tstore_dbseqnum
$pnn "$test_db" 5
196 echo "Set __db_sequence_number__ to 7 on node 0"
197 db_ctdb_tstore_dbseqnum
0 "$test_db" 7
199 echo "Set __db_sequence_number__ to 8 on node 1"
200 db_ctdb_tstore_dbseqnum
1 "$test_db" 8
204 echo force a recovery
205 try_command_on_node
0 $CTDB recover
207 # check that we now have both records on node 0
208 num_records
=$
(db_ctdb_cattdb_count_records
0 "$test_db")
209 if [ $num_records = "1" ] ; then
210 echo "OK: databases were not blended"
212 echo "BAD: we did not end up with the expected single record after the recovery"