|
| 1 | +––– input ––– |
| 2 | +set -b +m |
| 3 | +––– output ––– |
| 4 | +––– comment ––– |
| 5 | +Limit searchd to 4 threads for consistent conflict detection (add only if not present) |
| 6 | +––– input ––– |
| 7 | +grep -q 'threads = 4' test/clt-tests/base/searchd-with-flexible-ports.conf || sed -i '/searchd {/a\ threads = 4' test/clt-tests/base/searchd-with-flexible-ports.conf |
| 8 | +––– output ––– |
| 9 | +––– input ––– |
| 10 | +export INSTANCE=1 |
| 11 | +––– output ––– |
| 12 | +––– block: ../base/replication/start-searchd-precach ––– |
| 13 | +––– input ––– |
| 14 | +export INSTANCE=2 |
| 15 | +––– output ––– |
| 16 | +––– block: ../base/replication/start-searchd-precach ––– |
| 17 | +––– input ––– |
| 18 | +export INSTANCE=3 |
| 19 | +––– output ––– |
| 20 | +––– block: ../base/replication/start-searchd-precach ––– |
| 21 | +––– comment ––– |
| 22 | +Create 3-node cluster and add test table |
| 23 | +––– input ––– |
| 24 | +mkdir /var/{lib,log}/manticore-{1,2,3}/test |
| 25 | +––– output ––– |
| 26 | +––– input ––– |
| 27 | +mysql -h0 -P1306 -e "CREATE CLUSTER test 'test' as path"; echo $? |
| 28 | +––– output ––– |
| 29 | +0 |
| 30 | +––– input ––– |
| 31 | +mysql -h0 -P2306 -e "JOIN CLUSTER test at '127.0.0.1:1312' 'test' as path"; echo $? |
| 32 | +––– output ––– |
| 33 | +0 |
| 34 | +––– input ––– |
| 35 | +mysql -h0 -P3306 -e "JOIN CLUSTER test at '127.0.0.1:1312' 'test' as path"; echo $? |
| 36 | +––– output ––– |
| 37 | +0 |
| 38 | +––– input ––– |
| 39 | +mysql -h0 -P1306 -e "CREATE TABLE tbl1 (id bigint, attr1 int)"; echo $? |
| 40 | +––– output ––– |
| 41 | +0 |
| 42 | +––– input ––– |
| 43 | +mysql -h0 -P1306 -e "ALTER CLUSTER test ADD tbl1"; echo $? |
| 44 | +––– output ––– |
| 45 | +0 |
| 46 | +––– input ––– |
| 47 | +mysql -h0 -P1306 -e "INSERT INTO test:tbl1 (id, attr1) VALUES (1,1), (3,2), (10,3), (11,4), (12,5), (13,6), (14,7), (15,8), (20,9)"; echo $? |
| 48 | +––– output ––– |
| 49 | +0 |
| 50 | +––– input ––– |
| 51 | +mysql -h0 -P1306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 52 | +––– output ––– |
| 53 | +*************************** 1. row *************************** |
| 54 | +9 |
| 55 | +––– input ––– |
| 56 | +mysql -h0 -P2306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 57 | +––– output ––– |
| 58 | +*************************** 1. row *************************** |
| 59 | +9 |
| 60 | +––– input ––– |
| 61 | +mysql -h0 -P3306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 62 | +––– output ––– |
| 63 | +*************************** 1. row *************************** |
| 64 | +9 |
| 65 | +––– comment ––– |
| 66 | +Start background load to increase conflict probability |
| 67 | +––– input ––– |
| 68 | +manticore-load --host=127.0.0.1 --threads=4 --port=1306 --query="REPLACE INTO test:tbl1 (id, attr1) VALUES (%RAND, %RAND)" --host=127.0.0.1 --port=2306 --together > /dev/null 2>&1 & LOAD_PID=$!; sleep 1; echo "Load started: $LOAD_PID" |
| 69 | +––– output ––– |
| 70 | +Load started: %{NUMBER} |
| 71 | +––– comment ––– |
| 72 | +Test 1: UPDATE different doc & REPLACE different doc (NO conflict expected) |
| 73 | +––– input ––– |
| 74 | +mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=1 WHERE id=13" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (10, 999)" & wait |
| 75 | +––– output ––– |
| 76 | +––– comment ––– |
| 77 | +Test 2: REPLACE different docs (NO conflict expected) |
| 78 | +––– input ––– |
| 79 | +mysql -h0 -P2306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (11, 111)" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (10, 101)" & wait |
| 80 | +––– output ––– |
| 81 | +––– comment ––– |
| 82 | +Test 3: DELETE & REPLACE different docs (NO conflict expected) |
| 83 | +––– input ––– |
| 84 | +mysql -h0 -P2306 -e "DELETE FROM test:tbl1 WHERE id=3" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (10, 102)" & wait |
| 85 | +––– output ––– |
| 86 | +––– comment ––– |
| 87 | +Test 4: INSERT different ids (NO conflict expected) |
| 88 | +––– input ––– |
| 89 | +mysql -h0 -P2306 -e "INSERT INTO test:tbl1 (id, attr1) VALUES (100, 1)" & mysql -h0 -P1306 -e "INSERT INTO test:tbl1 (id, attr1) VALUES (200, 2)" & wait |
| 90 | +––– output ––– |
| 91 | +––– comment ––– |
| 92 | +Test 5: UPDATE & REPLACE same doc (CONFLICT expected) - run 30 times |
| 93 | +––– input ––– |
| 94 | +mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (13, 6)"; sleep 2 |
| 95 | +––– output ––– |
| 96 | +––– input ––– |
| 97 | +conflicts=0; for i in {1..30}; do result=$( (mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=1 WHERE id=13" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (13, 999)" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 98 | +––– output ––– |
| 99 | +Conflicts: %{NUMBER}/30 |
| 100 | +PASS |
| 101 | +––– comment ––– |
| 102 | +Test 6: UPDATE WHERE id> & REPLACE (CONFLICT expected) - run 30 times |
| 103 | +––– input ––– |
| 104 | +conflicts=0; for i in {1..30}; do result=$( (mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=1 WHERE id>13" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (14, 888)" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 105 | +––– output ––– |
| 106 | +Conflicts: %{NUMBER}/30 |
| 107 | +PASS |
| 108 | +––– comment ––– |
| 109 | +Test 7: UPDATE WHERE attr & REPLACE (CONFLICT expected) - run 30 times |
| 110 | +––– input ––– |
| 111 | +conflicts=0; for i in {1..30}; do mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (3, 2)" > /dev/null 2>&1; sleep 3; result=$( (mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=1 WHERE attr1=2" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (3, 333)" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 112 | +––– output ––– |
| 113 | +Conflicts: %{NUMBER}/30 |
| 114 | +PASS |
| 115 | +––– comment ––– |
| 116 | +Test 8: UPDATE WHERE attr & DELETE (CONFLICT expected) - run 30 times |
| 117 | +––– input ––– |
| 118 | +conflicts=0; for i in {1..30}; do mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (3, 2)" > /dev/null 2>&1; sleep 3; result=$( (mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=1 WHERE attr1=2" & mysql -h0 -P1306 -e "DELETE FROM test:tbl1 WHERE id=3" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 119 | +––– output ––– |
| 120 | +Conflicts: %{NUMBER}/30 |
| 121 | +PASS |
| 122 | +––– comment ––– |
| 123 | +Test 9: DELETE & REPLACE same doc (CONFLICT expected) - run 30 times |
| 124 | +––– input ––– |
| 125 | +conflicts=0; for i in {1..30}; do mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (3, 2)" > /dev/null 2>&1; sleep 3; result=$( (mysql -h0 -P2306 -e "DELETE FROM test:tbl1 WHERE id=3" & mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (3, 303)" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 126 | +––– output ––– |
| 127 | +Conflicts: %{NUMBER}/30 |
| 128 | +PASS |
| 129 | +––– comment ––– |
| 130 | +Test 10: 2x DELETE same doc (CONFLICT expected) - run 30 times |
| 131 | +––– input ––– |
| 132 | +conflicts=0; for i in {1..30}; do mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (1, 1)" > /dev/null 2>&1; sleep 3; result=$( (mysql -h0 -P2306 -e "DELETE FROM test:tbl1 WHERE id=1" & mysql -h0 -P1306 -e "DELETE FROM test:tbl1 WHERE id=1" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 133 | +––– output ––– |
| 134 | +Conflicts: %{NUMBER}/30 |
| 135 | +PASS |
| 136 | +––– comment ––– |
| 137 | +Test 11: 2x UPDATE same doc (CONFLICT expected) - run 30 times |
| 138 | +––– input ––– |
| 139 | +conflicts=0; for i in {1..30}; do result=$( (mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=111 WHERE id=15" & mysql -h0 -P1306 -e "UPDATE test:tbl1 SET attr1=222 WHERE id=15" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 140 | +––– output ––– |
| 141 | +Conflicts: %{NUMBER}/30 |
| 142 | +PASS |
| 143 | +––– comment ––– |
| 144 | +Test 12: 3x REPLACE different docs on 3 nodes (NO conflict expected) |
| 145 | +––– input ––– |
| 146 | +mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (1, 1001)" & mysql -h0 -P2306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (10, 1010)" & mysql -h0 -P3306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (20, 1020)" & wait |
| 147 | +––– output ––– |
| 148 | +––– comment ––– |
| 149 | +Test 13: 3x UPDATE same doc on 3 nodes (CONFLICT expected) - run 30 times |
| 150 | +––– input ––– |
| 151 | +conflicts=0; for i in {1..30}; do result=$( (mysql -h0 -P1306 -e "UPDATE test:tbl1 SET attr1=100 WHERE id=12" & mysql -h0 -P2306 -e "UPDATE test:tbl1 SET attr1=200 WHERE id=12" & mysql -h0 -P3306 -e "UPDATE test:tbl1 SET attr1=300 WHERE id=12" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 152 | +––– output ––– |
| 153 | +Conflicts: %{NUMBER}/30 |
| 154 | +PASS |
| 155 | +––– comment ––– |
| 156 | +Test 14: 2x DELETE + REPLACE on 3 nodes (CONFLICT expected) - run 30 times |
| 157 | +––– input ––– |
| 158 | +conflicts=0; for i in {1..30}; do mysql -h0 -P1306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (14, 14)" > /dev/null 2>&1; sleep 3; result=$( (mysql -h0 -P1306 -e "DELETE FROM test:tbl1 WHERE id=14" & mysql -h0 -P2306 -e "DELETE FROM test:tbl1 WHERE id=14" & mysql -h0 -P3306 -e "REPLACE INTO test:tbl1 (id, attr1) VALUES (15, 1500)" & wait) 2>&1 ); if echo "$result" | grep -q "error at PostRollback"; then ((conflicts++)); fi; done; echo "Conflicts: $conflicts/30"; test $conflicts -ge 1 && echo "PASS" || echo "FAIL" |
| 159 | +––– output ––– |
| 160 | +Conflicts: %{NUMBER}/30 |
| 161 | +PASS |
| 162 | +––– comment ––– |
| 163 | +Stop background load |
| 164 | +––– input ––– |
| 165 | +kill $LOAD_PID 2>/dev/null; wait $LOAD_PID 2>/dev/null; echo "Load stopped" |
| 166 | +––– output ––– |
| 167 | +Load stopped |
| 168 | +––– comment ––– |
| 169 | +Final verification: Check synchronization and no FATAL errors |
| 170 | +––– input ––– |
| 171 | +mysql -h0 -P1306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 172 | +––– output ––– |
| 173 | +*************************** 1. row *************************** |
| 174 | +%{NUMBER} |
| 175 | +––– input ––– |
| 176 | +mysql -h0 -P2306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 177 | +––– output ––– |
| 178 | +*************************** 1. row *************************** |
| 179 | +%{NUMBER} |
| 180 | +––– input ––– |
| 181 | +mysql -h0 -P3306 -NB -e "SELECT COUNT(*) FROM test:tbl1\G" |
| 182 | +––– output ––– |
| 183 | +*************************** 1. row *************************** |
| 184 | +%{NUMBER} |
| 185 | +––– input ––– |
| 186 | +mysql -h0 -P1306 -e "SELECT * FROM test:tbl1" > /tmp/node1.txt; mysql -h0 -P2306 -e "SELECT * FROM test:tbl1" > /tmp/node2.txt; mysql -h0 -P3306 -e "SELECT * FROM test:tbl1" > /tmp/node3.txt; diff /tmp/node1.txt /tmp/node2.txt && diff /tmp/node2.txt /tmp/node3.txt && echo "All nodes synchronized" || echo "Discrepancies detected" |
| 187 | +––– output ––– |
| 188 | +All nodes synchronized |
| 189 | +––– input ––– |
| 190 | +for i in 1 2 3; do grep -q 'FATAL:' /var/log/manticore-${i}/searchd.log && echo "Node #$i has FATAL" || echo "Node #$i OK"; done |
| 191 | +––– output ––– |
| 192 | +Node #1 OK |
| 193 | +Node #2 OK |
| 194 | +Node #3 OK |
0 commit comments