6 The persistent databases are recovered using sequence number.
7 The recovery is performed by picking the copy of the database from the
8 node that has the highest sequence number and ignore the content on all
14 * An active CTDB cluster with at least 2 active nodes.
18 1. Verify that the status on all of the ctdb nodes is 'OK'.
19 2. create a persistent test database
20 3. test that no seqnum record blends the database during recovery
21 4. test that seqnum record does not blend the database during recovery
25 * that 3,4 will recover the highest seqnum database
30 . "${TEST_SCRIPTS_DIR}/integration.bash"
39 ctdb_restart_when_done
41 try_command_on_node 0 "$CTDB listnodes"
42 num_nodes=$(echo "$out" | wc -l)
44 add_record_per_node ()
47 while [ $_i -lt $num_nodes ] ; do
50 echo "Store key(${_k}) data(${_d}) on node ${_i}"
51 db_ctdb_tstore $_i "$test_db" "$_k" "$_d"
56 test_db="persistent_test.tdb"
57 echo "Create persistent test database \"$test_db\""
58 try_command_on_node 0 $CTDB attach "$test_db" persistent
61 # If no __db_sequence_number__ recover whole database
65 echo "Test that no __db_sequence_number__ does not blend the database during recovery"
68 echo "Wipe the test database"
69 try_command_on_node 0 $CTDB wipedb "$test_db"
75 try_command_on_node 0 $CTDB recover
77 # Check that we now have 1 record on node 0
78 num_records=$(db_ctdb_cattdb_count_records 0 "$test_db")
79 if [ $num_records = "1" ] ; then
80 echo "OK: databases were not blended"
82 echo "BAD: we did not end up with the expected single record after the recovery"
88 # If __db_sequence_number__ recover whole database
92 echo test that __db_sequence_number__ does not blend the database during recovery
95 echo wipe the test database
96 try_command_on_node 0 $CTDB wipedb persistent_test.tdb
100 echo "Add __db_sequence_number__==5 record to all nodes"
102 while [ $pnn -lt $num_nodes ] ; do
103 db_ctdb_tstore_dbseqnum $pnn "$test_db" 5
107 echo "Set __db_sequence_number__ to 7 on node 0"
108 db_ctdb_tstore_dbseqnum 0 "$test_db" 7
110 echo "Set __db_sequence_number__ to 8 on node 1"
111 db_ctdb_tstore_dbseqnum 1 "$test_db" 8
115 echo force a recovery
116 try_command_on_node 0 $CTDB recover
118 # check that we now have both records on node 0
119 num_records=$(db_ctdb_cattdb_count_records 0 "$test_db")
120 if [ $num_records = "1" ] ; then
121 echo "OK: databases were not blended"
123 echo "BAD: we did not end up with the expected single record after the recovery"