Commit 1f26d08
committed
PS-9391 Fixes replication break error because of HASH_SCAN
https://perconadev.atlassian.net/browse/PS-9391
Problem
=======
When a replica's slave_rows_search_algorithms is set to HASH_SCAN, the
replication may break with HA_ERR_KEY_NOT_FOUND.
Analysis
========
When a replica's slave_rows_search_algorithms is set to HASH_SCAN,
it prepares a unique key list for all the rows in a particular Row_event.
The same unique key list will later be used to retrieve all tuples associated
to each key in the list from storage engine. In the case of multiple updates
targeted at the same row like how it is shown in the testcase, it may happen
that this unique key list filled with entries which don't exist yet in the table.
This is a problem when there is an intermediate update which changes the value
of the index column to a lesser value than the original entry and that changed
value is used in another update as shown in the second part of the testcase.
It is an issue because the unique key list is a std::set which internally
sorts it's entries. When this sorting happens, the first entry of the list
could potentially be a value which doesn't exist in the table and the when
it is searched in next_record_scan() method, it fails returning
HA_ERR_KEY_NOT_FOUND error.
Solution
========
Instead of using std::set to store the distinct keys, a combination of
unordered_set and a list is used to preserve the original order of
updates and avoid duplicates at the same time which prevents the side
effects of sorting.1 parent f01c613 commit 1f26d08
File tree
4 files changed
+182
-23
lines changed- mysql-test/suite/rpl
- r
- t
- sql
4 files changed
+182
-23
lines changedLines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
Lines changed: 84 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7870 | 7870 | | |
7871 | 7871 | | |
7872 | 7872 | | |
7873 | | - | |
| 7873 | + | |
7874 | 7874 | | |
7875 | 7875 | | |
7876 | 7876 | | |
| |||
7961 | 7961 | | |
7962 | 7962 | | |
7963 | 7963 | | |
7964 | | - | |
| 7964 | + | |
7965 | 7965 | | |
7966 | 7966 | | |
7967 | 7967 | | |
| |||
9052 | 9052 | | |
9053 | 9053 | | |
9054 | 9054 | | |
9055 | | - | |
9056 | | - | |
9057 | | - | |
| 9055 | + | |
| 9056 | + | |
| 9057 | + | |
9058 | 9058 | | |
9059 | 9059 | | |
9060 | 9060 | | |
| |||
9088 | 9088 | | |
9089 | 9089 | | |
9090 | 9090 | | |
9091 | | - | |
9092 | | - | |
9093 | | - | |
9094 | | - | |
9095 | | - | |
| 9091 | + | |
| 9092 | + | |
| 9093 | + | |
| 9094 | + | |
9096 | 9095 | | |
9097 | | - | |
9098 | | - | |
| 9096 | + | |
| 9097 | + | |
9099 | 9098 | | |
9100 | 9099 | | |
9101 | 9100 | | |
| |||
9142 | 9141 | | |
9143 | 9142 | | |
9144 | 9143 | | |
9145 | | - | |
9146 | | - | |
| 9144 | + | |
9147 | 9145 | | |
| 9146 | + | |
9148 | 9147 | | |
9149 | 9148 | | |
9150 | 9149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
2882 | 2882 | | |
2883 | 2883 | | |
2884 | 2884 | | |
2885 | | - | |
| 2885 | + | |
2886 | 2886 | | |
2887 | 2887 | | |
2888 | 2888 | | |
2889 | 2889 | | |
2890 | | - | |
| 2890 | + | |
2891 | 2891 | | |
2892 | | - | |
| 2892 | + | |
2893 | 2893 | | |
2894 | | - | |
| 2894 | + | |
2895 | 2895 | | |
2896 | 2896 | | |
2897 | 2897 | | |
2898 | | - | |
| 2898 | + | |
2899 | 2899 | | |
2900 | 2900 | | |
2901 | | - | |
| 2901 | + | |
2902 | 2902 | | |
2903 | 2903 | | |
2904 | 2904 | | |
2905 | 2905 | | |
2906 | 2906 | | |
2907 | | - | |
2908 | | - | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
2909 | 2930 | | |
2910 | 2931 | | |
2911 | 2932 | | |
| |||
0 commit comments