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 . ctdb_test_functions.bash
51 try_command_on_node 0 "$CTDB listnodes"
52 num_nodes=$(echo "$out" | wc -l)
54 # create a temporary persistent database to test with
55 echo create persistent test database persistent_test.tdb
56 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb attach persistent_test.tdb persistent
59 # set RecoverPDBBySeqNum=0
60 echo "setting RecoverPDBBySeqNum to 0"
61 try_command_on_node -q all $CTDB_TEST_WRAPPER ctdb setvar RecoverPDBBySeqNum 0
66 # If RecoverPDBBySeqNum==0 and no __db_sequence_number__
67 # recover record by record
71 echo test that RecoverPDBBySeqNum==0 and no __db_sequence_number__ blends the database during recovery
72 echo wipe the test database
73 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb
75 # add one record to node 0 key==ABC data==ABC
76 TDB=`try_command_on_node -v -q 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
77 echo "store key(ABC) data(ABC) on node 0"
78 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243
80 # add one record to node 1 key==DEF data==DEF
81 TDB=`try_command_on_node -v -q 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
82 echo "store key(DEF) data(DEF) on node 1"
83 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546
87 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb recover
89 # check that we now have both records on node 0
90 num_records=$(try_command_on_node -v -pq 0 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | egrep "ABC|DEF" | wc -l)
91 [ $num_records != "2" ] && {
92 echo "BAD: we did not end up with the expected two records after the recovery"
95 echo "OK. databases were blended"
100 # If RecoverPDBBySeqNum==0 and __db_sequence_number__
101 # recover record by record
105 echo test that RecoverPDBBySeqNum==0 and __db_sequence_number__ blends the database during recovery
106 echo wipe the test database
107 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb
109 echo "add __db_sequence_number__==5 record to all nodes"
110 try_command_on_node -v 0 $CTDB_TEST_WRAPPER ctdb nodestatus all | grep pnn | sed -e"s/^pnn://" -e "s/ .*//" | while read PNN; do
111 TDB=`try_command_on_node -v -q $PNN $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
112 try_command_on_node -q $PNN $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000500000000000000
115 # add one record to node 0 key==ABC data==ABC
116 TDB=`try_command_on_node -v -q 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
117 echo "store key(ABC) data(ABC) on node 0"
118 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243
119 echo "add __db_sequence_number__==7 record to node 0"
120 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000700000000000000
122 # add one record to node 1 key==DEF data==DEF
123 TDB=`try_command_on_node -v -q 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
124 echo "store key(DEF) data(DEF) on node 1"
125 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546
126 echo "add __db_sequence_number__==8 record to node 1"
127 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000800000000000000
130 echo force a recovery
131 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb recover
133 # check that we now have both records on node 0
134 num_records=$(try_command_on_node -v -pq 0 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | egrep "ABC|DEF" | wc -l)
135 [ $num_records != "2" ] && {
136 echo "BAD: we did not end up with the expected two records after the recovery"
139 echo "OK. databases were blended"
143 # set RecoverPDBBySeqNum=1
145 echo "setting RecoverPDBBySeqNum to 1"
146 try_command_on_node -q all $CTDB_TEST_WRAPPER ctdb setvar RecoverPDBBySeqNum 1
151 # If RecoverPDBBySeqNum==1 and no __db_sequence_number__
152 # recover record by record
156 echo test that RecoverPDBBySeqNum==1 and no __db_sequence_number__ blends the database during recovery
157 echo wipe the test database
158 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb
160 # add one record to node 0 key==ABC data==ABC
161 TDB=`try_command_on_node -v -q 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
162 echo "store key(ABC) data(ABC) on node 0"
163 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243
165 # add one record to node 1 key==DEF data==DEF
166 TDB=`try_command_on_node -v -q 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
167 echo "store key(DEF) data(DEF) on node 1"
168 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546
171 echo force a recovery
172 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb recover
174 # check that we now have both records on node 0
175 num_records=$(try_command_on_node -v -pq 0 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | egrep "ABC|DEF" | wc -l)
176 [ $num_records != "2" ] && {
177 echo "BAD: we did not end up with the expected two records after the recovery"
180 echo "OK. databases were blended"
185 # If RecoverPDBBySeqNum==1 and __db_sequence_number__
186 # recover whole database
190 echo test that RecoverPDBBySeqNum==1 and __db_sequence_number__ does not blend the database during recovery
191 echo wipe the test database
192 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb
194 echo "add __db_sequence_number__==5 record to all nodes"
195 try_command_on_node -v 0 $CTDB_TEST_WRAPPER ctdb nodestatus all | grep pnn | sed -e"s/^pnn://" -e "s/ .*//" | while read PNN; do
196 TDB=`try_command_on_node -v -q $PNN $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
197 try_command_on_node -q $PNN $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000500000000000000
201 # add one record to node 0 key==ABC data==ABC
202 TDB=`try_command_on_node -v -q 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
203 echo "store key(ABC) data(ABC) on node 0"
204 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243
205 echo "add __db_sequence_number__==7 record to node 0"
206 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000700000000000000
208 # add one record to node 1 key==DEF data==DEF
209 TDB=`try_command_on_node -v -q 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
210 echo "store key(DEF) data(DEF) on node 1"
211 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546
212 echo "add __db_sequence_number__==8 record to node 1"
213 try_command_on_node -q 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x5f5f64625f73657175656e63655f6e756d6265725f5f00 0x0700000000000000000000000000000000000000000000000800000000000000
216 echo force a recovery
217 try_command_on_node -q 0 $CTDB_TEST_WRAPPER ctdb recover
219 # check that we now have both records on node 0
220 num_records=$(try_command_on_node -v -pq 0 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | egrep "ABC|DEF" | wc -l)
221 [ $num_records != "1" ] && {
222 echo "BAD: we did not end up with the expected single record after the recovery"
226 echo "OK. databases were not blended"
230 # set RecoverPDBBySeqNum=1
231 echo "setting RecoverPDBBySeqNum back to 0"
232 try_command_on_node -q all $CTDB_TEST_WRAPPER ctdb setvar RecoverPDBBySeqNum 0