]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/tools/analyze_txn_stress_test.sh
8082606081235f588a95bcaf91944f23590a4a91
[ceph.git] / ceph / src / rocksdb / tools / analyze_txn_stress_test.sh
1 #!/bin/bash
2 # Usage:
3 # 1. Enable ROCKS_LOG_DETAILS in util/logging.h
4 # 2. Run ./transaction_test --gtest_filter="MySQLStyleTransactionTest/MySQLStyleTransactionTest.TransactionStressTest/*" --gtest_break_on_failure
5 # 3. SET=1 # 2 or 3
6 # 4. LOG=/dev/shm/transaction_testdb_8600601584148590297/LOG
7 # 5. grep RandomTransactionVerify $LOG | cut -d' ' -f 12 | sort -n # to find verify snapshots
8 # 5. vn=1345
9 # 6. vn_1=1340
10 # 4. . tools/tools/analyze_txn_stress_test.sh
11 echo Input params:
12 # The rocksdb LOG path
13 echo $LOG
14 # Snapshot at which we got RandomTransactionVerify failure
15 echo $vn
16 # The snapshot before that where RandomTransactionVerify passed
17 echo $vn_1
18 # The stress tests use 3 sets, one or more might have shown inconsistent results.
19 SET=${SET-1} # 1 or 2 or 3
20 echo Checking set number $SET
21
22 # Find the txns that committed between the two snapshots, and gather their changes made by them in /tmp/changes.txt
23 # 2019/02/28-15:25:51.655477 7fffec9ff700 [DEBUG] [ilities/transactions/write_prepared_txn_db.cc:416] Txn 68497 Committing with 68498
24 grep Committing $LOG | awk '{if ($9 <= vn && $9 > vn_1) print $0}' vn=$vn vn_1=${vn_1} > /tmp/txn.txt
25 # 2019/02/28-15:25:49.046464 7fffe81f5700 [DEBUG] [il/transaction_test_util.cc:216] Commit of 65541 OK (txn12936193128775589751-9089)
26 for i in `cat /tmp/txn.txt | awk '{print $6}'`; do grep "Commit of $i " $LOG; done > /tmp/names.txt
27 for n in `cat /tmp/names.txt | awk '{print $9}'`; do grep $n $LOG; done > /tmp/changes.txt
28 echo "Sum of the changes:"
29 cat /tmp/changes.txt | grep Insert | awk '{print $12}' | cut -d= -f1 | cut -d+ -f2 | awk '{sum+=$1} END{print sum}'
30
31 # Gather read values at each snapshot
32 # 2019/02/28-15:25:51.655926 7fffebbff700 [DEBUG] [il/transaction_test_util.cc:347] VerifyRead at 67972 (67693): 000230 value: 15983
33 grep "VerifyRead at ${vn_1} (.*): 000${SET}" $LOG | cut -d' ' -f 9- > /tmp/va.txt
34 grep "VerifyRead at ${vn} (.*): 000${SET}" $LOG | cut -d' ' -f 9- > /tmp/vb.txt
35
36 # For each key in the 2nd snapshot, find the value read by 1st, do the adds, and see if the results match.
37 IFS=$'\n'
38 for l in `cat /tmp/vb.txt`;
39 do
40 grep $l /tmp/va.txt > /dev/null ;
41 if [[ $? -ne 0 ]]; then
42 #echo $l
43 k=`echo $l | awk '{print $1}'`;
44 v=`echo $l | awk '{print $3}'`;
45 # 2019/02/28-15:25:19.350111 7fffe81f5700 [DEBUG] [il/transaction_test_util.cc:194] Insert (txn12936193128775589751-2298) OK snap: 16289 key:000219 value: 3772+95=3867
46 exp=`grep "\<$k\>" /tmp/changes.txt | tail -1 | cut -d= -f2`;
47 if [[ $v -ne $exp ]]; then echo $l; fi
48 else
49 k=`echo $l | awk '{print $1}'`;
50 grep "\<$k\>" /tmp/changes.txt
51 fi;
52 done
53
54 # Check that all the keys read in the 1st snapshot are still visible in the 2nd
55 for l in `cat /tmp/va.txt`;
56 do
57 k=`echo $l | awk '{print $1}'`;
58 grep "\<$k\>" /tmp/vb.txt > /dev/null
59 if [[ $? -ne 0 ]]; then
60 echo missing key $k
61 fi
62 done
63
64 # The following found a bug in ValidateSnapshot. It checks if the adds on each key match up.
65 grep Insert /tmp/changes.txt | cut -d' ' -f 10 | sort | uniq > /tmp/keys.txt
66 for k in `cat /tmp/keys.txt`;
67 do
68 grep "\<$k\>" /tmp/changes.txt > /tmp/adds.txt;
69 # 2019/02/28-15:25:19.350111 7fffe81f5700 [DEBUG] [il/transaction_test_util.cc:194] Insert (txn12936193128775589751-2298) OK snap: 16289 key:000219 value: 3772+95=3867
70 START=`head -1 /tmp/adds.txt | cut -d' ' -f 12 | cut -d+ -f1`
71 END=`tail -1 /tmp/adds.txt | cut -d' ' -f 12 | cut -d= -f2`
72 ADDS=`cat /tmp/adds.txt | grep Insert | awk '{print $12}' | cut -d= -f1 | cut -d+ -f2 | awk '{sum+=$1} END{print sum}'`
73 EXP=$((START+ADDS))
74 # If first + all the adds != last then there was an issue with ValidateSnapshot.
75 if [[ $END -ne $EXP ]]; then echo inconsistent txn: $k $START+$ADDS=$END; cat /tmp/adds.txt; return 1; fi
76 done