Merge lp:~laurynas-biveinis/percona-server/ahi-partitions-5.6-5.6 into lp:percona-server/5.6
- ahi-partitions-5.6-5.6
- Merge into 5.6
Status: | Superseded | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~laurynas-biveinis/percona-server/ahi-partitions-5.6-5.6 | ||||||||||||
Merge into: | lp:percona-server/5.6 | ||||||||||||
Diff against target: |
1897 lines (+678/-212) 30 files modified
Percona-Server/mysql-test/suite/innodb/r/percona_ahi_partitions.result (+33/-0) Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions-master.opt (+1/-0) Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions.test (+67/-0) Percona-Server/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result (+9/-0) Percona-Server/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test (+14/-0) Percona-Server/storage/innobase/btr/btr0cur.cc (+6/-5) Percona-Server/storage/innobase/btr/btr0sea.cc (+212/-117) Percona-Server/storage/innobase/buf/buf0buf.cc (+3/-1) Percona-Server/storage/innobase/dict/dict0dict.cc (+4/-2) Percona-Server/storage/innobase/ha/ha0ha.cc (+30/-4) Percona-Server/storage/innobase/handler/ha_innodb.cc (+7/-0) Percona-Server/storage/innobase/handler/xtradb_i_s.cc (+28/-28) Percona-Server/storage/innobase/include/btr0sea.h (+52/-2) Percona-Server/storage/innobase/include/btr0sea.ic (+79/-2) Percona-Server/storage/innobase/include/btr0types.h (+4/-4) Percona-Server/storage/innobase/include/buf0buf.h (+2/-0) Percona-Server/storage/innobase/include/mtr0log.ic (+1/-0) Percona-Server/storage/innobase/include/que0que.h (+1/-0) Percona-Server/storage/innobase/include/read0read.h (+1/-0) Percona-Server/storage/innobase/include/trx0roll.h (+1/-0) Percona-Server/storage/innobase/include/trx0trx.h (+1/-4) Percona-Server/storage/innobase/include/trx0trx.ic (+8/-4) Percona-Server/storage/innobase/include/univ.i (+0/-1) Percona-Server/storage/innobase/os/os0file.cc (+1/-0) Percona-Server/storage/innobase/row/row0sel.cc (+71/-24) Percona-Server/storage/innobase/srv/srv0conc.cc (+1/-0) Percona-Server/storage/innobase/srv/srv0srv.cc (+20/-13) Percona-Server/storage/innobase/sync/sync0sync.cc (+19/-1) Percona-Server/storage/innobase/trx/trx0trx.cc (+1/-0) Percona-Server/storage/innobase/ut/ut0ut.cc (+1/-0) |
||||||||||||
To merge this branch: | bzr merge lp:~laurynas-biveinis/percona-server/ahi-partitions-5.6-5.6 | ||||||||||||
Related bugs: |
|
||||||||||||
Related blueprints: |
Port AHI partitions to 5.6
(Essential)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Needs Fixing | ||
Review via email: mp+182943@code.launchpad.net |
This proposal supersedes a proposal from 2013-08-28.
This proposal has been superseded by a proposal from 2013-08-29.
Commit message
Description of the change
3rd MP:
Review comments addressed,
http://
2nd MP:
Review comments addressed.
http://
Testsuite changes only, no new MTR 8 partitions Jenkins run.
1st MP:
Port AHI partitions from 5.5 to 5.6, implementing https:/
Default Jenkins run at
http://
and additional MTR --mysqld=
http://
Port adaptive hash index partitions from 5.5.
There are no major algorithmic differences from the 5.5 version. The
are minor differences from the 5.5 version:
- simplify latching changes in row_search_
a helper function trx_search_
trx_search_
bothering to compute an X waiters bit mask in phase 0 but checking
whether any X waiter is present instead;
- add additional latching order enforcement code to
sync_
- some comments in surrounding code were updated to reflect the
partitioning;
- added missing header and arg comments. Add function attributes to
btr_search_
function btr_search_
- merged btr_search_
adjusted UNIV_LIKELY/
expected reality;
- instead of adding an outer loop to it as in 5.5, rename
btr_search_
new function btr_search_
- instead of disabling UNIV_SYNC_DEBUG checks in ha_clear(),
ha_delete_
implement a helper function ha_assert_
called from them;
- fix AHI-related code formatting in
xtradb_
- expanded the sys_vars suite test
innodb_
At the same time fix bug 1216815 /
http://
from UNIV_DEBUG) by re-enabling it in univ.i.
Merge bug 1214449 (Adaptive hash index partitions not tested in MTR)
fix by merging the testcase.
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
More comments on test cases:
> === added file 'Percona-
> --- Percona-
> +++ Percona-
> @@ -0,0 +1,32 @@
> +# A sys_vars suite test from innodb_
> +# innodb_
> +
> +--source include/
> +
> +SELECT COUNT(@
> +
I’m not sure what the above check is supposed to verify. Apparently that
the variable exists and is not NULL. But if that’s the case, the test
would fail anyway.
Just checking the default value would make sense. But it’s not checked
anywhere in the test.
> +--error ER_INCORRECT_
> +SET @@GLOBAL.
> +
> +SELECT COUNT(@
> +
The same check again?
> +SELECT COUNT(VARIABLE_
> +FROM INFORMATION_
> +WHERE VARIABLE_
> +
> +SELECT @@GLOBAL.
> +FROM INFORMATION_
> +WHERE VARIABLE_
> +
> +SELECT @@innodb_
> +
> +SELECT COUNT(@
> +
> +--Error ER_INCORRECT_
> +SELECT COUNT(@
> +
> +--Error ER_INCORRECT_
> +SELECT COUNT(@
> +
> +--Error ER_BAD_FIELD_ERROR
> +SELECT innodb_
I don’t know the purpose of all these checks which are replicated from
one test case to another. It looks like some incompetent (to put it
mildly) person first wrote them, and then everyone else copies that
stuff whenever he needs to implement a variable test.
What I would expect to see in a sys_var.*_basic test is verifying
the variable type, and default/min/max values. Instead most tests do
some acrobatics with I_S and different syntax to access the variable.
Please also consider backporting it to 5.5 as I mentioned in the 5.5 MP.
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
> More comments on test cases:
...
> I don’t know the purpose of all these checks which are replicated from
> one test case to another. It looks like some incompetent (to put it
> mildly) person first wrote them, and then everyone else copies that
> stuff whenever he needs to implement a variable test.
>
> What I would expect to see in a sys_var.*_basic test is verifying
> the variable type, and default/min/max values. Instead most tests do
> some acrobatics with I_S and different syntax to access the variable.
I absolutely agree with all these comments and obviously I have cut some corners when copied/
What do you think about the following? The variable is global-only, read-only. Check the default, check the read-only-ness, check that global only. For 5.5 too.
# A sys_vars suite test from innodb_
--source include/
SELECT @@GLOBAL.
--error ER_INCORRECT_
SET @@GLOBAL.
--error ER_INCORRECT_
SELECT @@LOCAL.
--error ER_INCORRECT_
SELECT @@SESSION.
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
On Tue, Aug 27 2013 15:52:14 +0000, Laurynas Biveinis wrote:
>> More comments on test cases:
> ...
>> I don’t know the purpose of all these checks which are replicated from
>> one test case to another. It looks like some incompetent (to put it
>> mildly) person first wrote them, and then everyone else copies that
>> stuff whenever he needs to implement a variable test.
>>
>> What I would expect to see in a sys_var.*_basic test is verifying
>> the variable type, and default/min/max values. Instead most tests do
>> some acrobatics with I_S and different syntax to access the variable.
>
> I absolutely agree with all these comments and obviously I have cut some corners when copied/
>
> What do you think about the following? The variable is global-only, read-only. Check the default, check the read-only-ness, check that global only. For 5.5 too.
>
> # A sys_vars suite test from innodb_
>
> --source include/
>
> SELECT @@GLOBAL.
>
> --error ER_INCORRECT_
> SET @@GLOBAL.
>
> --error ER_INCORRECT_
> SELECT @@LOCAL.
>
> --error ER_INCORRECT_
> SELECT @@SESSION.
OK.
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
Hi Laurynas,
As discussed on IRC, I’m only posting comments specific to the port
itself. I’ll handle everything else in the followup work on AHI.
On Wed, Aug 28 2013 13:59:04 +0400, Laurynas Biveinis wrote:
[...]
> - btr_search_
> + /* btr_search_
> + trx->has_
> + ut_ad(btr_
This assertion is wrong. We allow 64 AHI partitions in 64-bit
architectures in 5.5, and its documented. It’s just that the code
comment is wrong.
>
> - rw_lock_
> - SYNC_SEARCH_SYS);
> + btr_search_
> + mem_alloc(
What’s so temporal about btr_search_
sense in the single-lock code (though the reasoning for it is dubious),
but it correctly does not have “temp” in 5.5 code, as it’s a regular array.
[...]
> index = block->index;
> -
> - if (UNIV_LIKELY(
> -
> - rw_lock_
> -
> + if (UNIV_UNLIKELY(
> + rw_lock_
> return;
> }
>
> + ut_a(btr_
> +
Shouldn’t this be a debug assertion? btr_search_latch is basically a
constant attribute of each index. So it’s more of a code invariant.
[...]
> -btr_search_
> -/*====
> +btr_search_
> +/*====
> + ulint t)
> {
> ha_node_t* node;
> ulint n_page_dumps = 0;
> @@ -1874,24 +1944,20 @@
>
> rec_offs_
>
> - rw_lock_
> - buf_pool_
> -
> - cell_count = hash_get_
> + cell_count = hash_get_
>
Why buf_pool_
being removed from btr_search_
[...]
> +ha_assert_
> +/*====
> + const hash_table_t* table) /*!<in: hash table to check */
> +{
> + ulint i;
> +
> + ut_ad(table-
> +
> + for (i = 0; i < btr_search_
> + if (btr_search_
> + break;
Braces.
[...]
> +/*****
> +Latches all adaptive hash index latches in shared mode. */
> +UNIV_INLINE
> +void
> +btr_search_
> +/*====
> +
> +/*****
> +Unlatches all adaptive hash index latches in shared mode. */
> +UNIV_INLINE
> +void
> +btr_search_
> +/*====
> +
These ones are declared and defined, but not used.
[...]
> === modified file 'Percona-
> --- Percona-
> +++ Percona-
> @@ -28,6 +28,7 @@
> #include "buf0buf.h"
> #include "buf0dblwr.h"
> #include "fsp0types.h"
> +#include "btr0types.h"
> #inc...
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
> Why buf_pool_
> being removed from btr_search_
A mistake, mix-up with the buffer pool mutex split patch.
> > +#include "btr0types.h"
>
> Why new #includes in mtr0log.ic, que0que.h and read0read.h, trx0roll.h,
> trx0trx.cc, ut0ut.cc and os0file.cc?
It's because trx0trx.ic needs btr stuff in trx_search_
Alexey Kopytov (akopytov) wrote : | # |
btr_search_
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
gah, removing.
Preview Diff
1 | === added file 'Percona-Server/mysql-test/suite/innodb/r/percona_ahi_partitions.result' | |||
2 | --- Percona-Server/mysql-test/suite/innodb/r/percona_ahi_partitions.result 1970-01-01 00:00:00 +0000 | |||
3 | +++ Percona-Server/mysql-test/suite/innodb/r/percona_ahi_partitions.result 2013-08-29 17:07:33 +0000 | |||
4 | @@ -0,0 +1,33 @@ | |||
5 | 1 | SELECT @@GLOBAL.innodb_adaptive_hash_index; | ||
6 | 2 | @@GLOBAL.innodb_adaptive_hash_index | ||
7 | 3 | 1 | ||
8 | 4 | SELECT @@GLOBAL.innodb_adaptive_hash_index_partitions; | ||
9 | 5 | @@GLOBAL.innodb_adaptive_hash_index_partitions | ||
10 | 6 | 4 | ||
11 | 7 | SET GLOBAL innodb_monitor_enable=module_adaptive_hash; | ||
12 | 8 | CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
13 | 9 | CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
14 | 10 | CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
15 | 11 | Filling tables | ||
16 | 12 | Querying | ||
17 | 13 | SELECT COUNT >= 6 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_pages_added'; | ||
18 | 14 | should_be_1 | ||
19 | 15 | 1 | ||
20 | 16 | SELECT COUNT >= 6 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_rows_added'; | ||
21 | 17 | should_be_1 | ||
22 | 18 | 1 | ||
23 | 19 | SELECT COUNT > 0 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_searches'; | ||
24 | 20 | should_be_1 | ||
25 | 21 | 1 | ||
26 | 22 | SELECT COUNT(*) > 0 AS should_be_1 FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE | ||
27 | 23 | WHERE PAGE_STATE LIKE "MEMORY"; | ||
28 | 24 | should_be_1 | ||
29 | 25 | 1 | ||
30 | 26 | SELECT COUNT(*) >= 6 AS should_be_1 FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE | ||
31 | 27 | WHERE IS_HASHED LIKE "YES"; | ||
32 | 28 | should_be_1 | ||
33 | 29 | 1 | ||
34 | 30 | SET GLOBAL innodb_monitor_disable=module_adaptive_hash; | ||
35 | 31 | DROP TABLE t1, t2, t3; | ||
36 | 32 | SET GLOBAL innodb_monitor_enable=default; | ||
37 | 33 | SET GLOBAL innodb_monitor_disable=default; | ||
38 | 0 | 34 | ||
39 | === added file 'Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions-master.opt' | |||
40 | --- Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions-master.opt 1970-01-01 00:00:00 +0000 | |||
41 | +++ Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions-master.opt 2013-08-29 17:07:33 +0000 | |||
42 | @@ -0,0 +1,1 @@ | |||
43 | 1 | --innodb-adaptive-hash-index-partitions=4 | ||
44 | 0 | 2 | ||
45 | === added file 'Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions.test' | |||
46 | --- Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions.test 1970-01-01 00:00:00 +0000 | |||
47 | +++ Percona-Server/mysql-test/suite/innodb/t/percona_ahi_partitions.test 2013-08-29 17:07:33 +0000 | |||
48 | @@ -0,0 +1,67 @@ | |||
49 | 1 | # | ||
50 | 2 | # Basic test for InnoDB adaptive hash index partitions. | ||
51 | 3 | # TODO: add another testcase that uses DEBUG_SYNC to check the partition locking | ||
52 | 4 | # | ||
53 | 5 | --source include/have_innodb.inc | ||
54 | 6 | |||
55 | 7 | # Check setup | ||
56 | 8 | SELECT @@GLOBAL.innodb_adaptive_hash_index; | ||
57 | 9 | SELECT @@GLOBAL.innodb_adaptive_hash_index_partitions; | ||
58 | 10 | |||
59 | 11 | SET GLOBAL innodb_monitor_enable=module_adaptive_hash; | ||
60 | 12 | |||
61 | 13 | # 6 index trees across 4 AHI partitions | ||
62 | 14 | CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
63 | 15 | CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
64 | 16 | CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c CHAR(200), UNIQUE INDEX b(b)) ENGINE=InnoDB; | ||
65 | 17 | |||
66 | 18 | --echo Filling tables | ||
67 | 19 | --disable_query_log | ||
68 | 20 | let $i=3; | ||
69 | 21 | while ($i) | ||
70 | 22 | { | ||
71 | 23 | eval INSERT INTO t1 VALUES ($i, $i, REPEAT("a", 200)); | ||
72 | 24 | eval INSERT INTO t2 VALUES ($i, $i, REPEAT("a", 200)); | ||
73 | 25 | eval INSERT INTO t3 VALUES ($i, $i, REPEAT("a", 200)); | ||
74 | 26 | dec $i; | ||
75 | 27 | } | ||
76 | 28 | |||
77 | 29 | --echo Querying | ||
78 | 30 | --disable_result_log | ||
79 | 31 | let $i=200; | ||
80 | 32 | while ($i) | ||
81 | 33 | { | ||
82 | 34 | SELECT b FROM t1 WHERE a=1; | ||
83 | 35 | SELECT a FROM t1 WHERE b=1; | ||
84 | 36 | SELECT b FROM t2 WHERE a=2; | ||
85 | 37 | SELECT a FROM t2 WHERE b=2; | ||
86 | 38 | SELECT b FROM t3 WHERE a=3; | ||
87 | 39 | SELECT a FROM t3 WHERE b=3; | ||
88 | 40 | dec $i; | ||
89 | 41 | } | ||
90 | 42 | --enable_result_log | ||
91 | 43 | --enable_query_log | ||
92 | 44 | |||
93 | 45 | # Some buffer pool pages should be hashed | ||
94 | 46 | SELECT COUNT >= 6 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_pages_added'; | ||
95 | 47 | # Some rows should be hashed | ||
96 | 48 | SELECT COUNT >= 6 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_rows_added'; | ||
97 | 49 | # AHI should have been used for queries, but the exact lower bound is hard to determine | ||
98 | 50 | SELECT COUNT > 0 as should_be_1 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'adaptive_hash_searches'; | ||
99 | 51 | |||
100 | 52 | # Buffer pool must contain AHI pages now | ||
101 | 53 | SELECT COUNT(*) > 0 AS should_be_1 FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE | ||
102 | 54 | WHERE PAGE_STATE LIKE "MEMORY"; | ||
103 | 55 | |||
104 | 56 | # Buffer pool must contain no less than the number of index trees hashed pages now | ||
105 | 57 | SELECT COUNT(*) >= 6 AS should_be_1 FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE | ||
106 | 58 | WHERE IS_HASHED LIKE "YES"; | ||
107 | 59 | |||
108 | 60 | SET GLOBAL innodb_monitor_disable=module_adaptive_hash; | ||
109 | 61 | |||
110 | 62 | DROP TABLE t1, t2, t3; | ||
111 | 63 | |||
112 | 64 | --disable_warnings | ||
113 | 65 | SET GLOBAL innodb_monitor_enable=default; | ||
114 | 66 | SET GLOBAL innodb_monitor_disable=default; | ||
115 | 67 | --enable_warnings | ||
116 | 0 | 68 | ||
117 | === added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result' | |||
118 | --- Percona-Server/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result 1970-01-01 00:00:00 +0000 | |||
119 | +++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result 2013-08-29 17:07:33 +0000 | |||
120 | @@ -0,0 +1,9 @@ | |||
121 | 1 | SELECT @@GLOBAL.innodb_adaptive_hash_index_partitions; | ||
122 | 2 | @@GLOBAL.innodb_adaptive_hash_index_partitions | ||
123 | 3 | 1 | ||
124 | 4 | SET @@GLOBAL.innodb_adaptive_hash_index_partitions=1; | ||
125 | 5 | ERROR HY000: Variable 'innodb_adaptive_hash_index_partitions' is a read only variable | ||
126 | 6 | SELECT @@LOCAL.innodb_adaptive_hash_index_partitions; | ||
127 | 7 | ERROR HY000: Variable 'innodb_adaptive_hash_index_partitions' is a GLOBAL variable | ||
128 | 8 | SELECT @@SESSION.innodb_adaptive_hash_index_partitions; | ||
129 | 9 | ERROR HY000: Variable 'innodb_adaptive_hash_index_partitions' is a GLOBAL variable | ||
130 | 0 | 10 | ||
131 | === added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test' | |||
132 | --- Percona-Server/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test 1970-01-01 00:00:00 +0000 | |||
133 | +++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test 2013-08-29 17:07:33 +0000 | |||
134 | @@ -0,0 +1,14 @@ | |||
135 | 1 | # A sys_vars suite test for innodb_adaptive_hash_index_partitions. | ||
136 | 2 | |||
137 | 3 | --source include/have_innodb.inc | ||
138 | 4 | |||
139 | 5 | SELECT @@GLOBAL.innodb_adaptive_hash_index_partitions; | ||
140 | 6 | |||
141 | 7 | --error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
142 | 8 | SET @@GLOBAL.innodb_adaptive_hash_index_partitions=1; | ||
143 | 9 | |||
144 | 10 | --error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
145 | 11 | SELECT @@LOCAL.innodb_adaptive_hash_index_partitions; | ||
146 | 12 | |||
147 | 13 | --error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
148 | 14 | SELECT @@SESSION.innodb_adaptive_hash_index_partitions; | ||
149 | 0 | 15 | ||
150 | === modified file 'Percona-Server/storage/innobase/btr/btr0cur.cc' | |||
151 | --- Percona-Server/storage/innobase/btr/btr0cur.cc 2013-08-14 03:57:21 +0000 | |||
152 | +++ Percona-Server/storage/innobase/btr/btr0cur.cc 2013-08-29 17:07:33 +0000 | |||
153 | @@ -536,7 +536,8 @@ | |||
154 | 536 | # ifdef UNIV_SEARCH_PERF_STAT | 536 | # ifdef UNIV_SEARCH_PERF_STAT |
155 | 537 | info->n_searches++; | 537 | info->n_searches++; |
156 | 538 | # endif | 538 | # endif |
158 | 539 | if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED | 539 | if ((rw_lock_get_writer(btr_search_get_latch(cursor->index->id)) |
159 | 540 | == RW_LOCK_NOT_LOCKED) | ||
160 | 540 | && latch_mode <= BTR_MODIFY_LEAF | 541 | && latch_mode <= BTR_MODIFY_LEAF |
161 | 541 | && info->last_hash_succ | 542 | && info->last_hash_succ |
162 | 542 | && !estimate | 543 | && !estimate |
163 | @@ -572,7 +573,7 @@ | |||
164 | 572 | 573 | ||
165 | 573 | if (has_search_latch) { | 574 | if (has_search_latch) { |
166 | 574 | /* Release possible search latch to obey latching order */ | 575 | /* Release possible search latch to obey latching order */ |
168 | 575 | rw_lock_s_unlock(&btr_search_latch); | 576 | rw_lock_s_unlock(btr_search_get_latch(cursor->index->id)); |
169 | 576 | } | 577 | } |
170 | 577 | 578 | ||
171 | 578 | /* Store the position of the tree latch we push to mtr so that we | 579 | /* Store the position of the tree latch we push to mtr so that we |
172 | @@ -895,7 +896,7 @@ | |||
173 | 895 | 896 | ||
174 | 896 | if (has_search_latch) { | 897 | if (has_search_latch) { |
175 | 897 | 898 | ||
177 | 898 | rw_lock_s_lock(&btr_search_latch); | 899 | rw_lock_s_lock(btr_search_get_latch(cursor->index->id)); |
178 | 899 | } | 900 | } |
179 | 900 | } | 901 | } |
180 | 901 | 902 | ||
181 | @@ -2162,13 +2163,13 @@ | |||
182 | 2162 | btr_search_update_hash_on_delete(cursor); | 2163 | btr_search_update_hash_on_delete(cursor); |
183 | 2163 | } | 2164 | } |
184 | 2164 | 2165 | ||
186 | 2165 | rw_lock_x_lock(&btr_search_latch); | 2166 | rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); |
187 | 2166 | } | 2167 | } |
188 | 2167 | 2168 | ||
189 | 2168 | row_upd_rec_in_place(rec, index, offsets, update, page_zip); | 2169 | row_upd_rec_in_place(rec, index, offsets, update, page_zip); |
190 | 2169 | 2170 | ||
191 | 2170 | if (is_hashed) { | 2171 | if (is_hashed) { |
193 | 2171 | rw_lock_x_unlock(&btr_search_latch); | 2172 | rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); |
194 | 2172 | } | 2173 | } |
195 | 2173 | 2174 | ||
196 | 2174 | btr_cur_update_in_place_log(flags, rec, index, update, | 2175 | btr_cur_update_in_place_log(flags, rec, index, update, |
197 | 2175 | 2176 | ||
198 | === modified file 'Percona-Server/storage/innobase/btr/btr0sea.cc' | |||
199 | --- Percona-Server/storage/innobase/btr/btr0sea.cc 2013-08-06 15:16:34 +0000 | |||
200 | +++ Percona-Server/storage/innobase/btr/btr0sea.cc 2013-08-29 17:07:33 +0000 | |||
201 | @@ -47,6 +47,9 @@ | |||
202 | 47 | Protected by btr_search_latch. */ | 47 | Protected by btr_search_latch. */ |
203 | 48 | UNIV_INTERN char btr_search_enabled = TRUE; | 48 | UNIV_INTERN char btr_search_enabled = TRUE; |
204 | 49 | 49 | ||
205 | 50 | /** Number of adaptive hash index partitions */ | ||
206 | 51 | UNIV_INTERN ulint btr_search_index_num; | ||
207 | 52 | |||
208 | 50 | /** A dummy variable to fool the compiler */ | 53 | /** A dummy variable to fool the compiler */ |
209 | 51 | UNIV_INTERN ulint btr_search_this_is_zero = 0; | 54 | UNIV_INTERN ulint btr_search_this_is_zero = 0; |
210 | 52 | 55 | ||
211 | @@ -68,9 +71,9 @@ | |||
212 | 68 | being updated in-place! We can use fact (1) to perform unique searches to | 71 | being updated in-place! We can use fact (1) to perform unique searches to |
213 | 69 | indexes. */ | 72 | indexes. */ |
214 | 70 | 73 | ||
216 | 71 | /* We will allocate the latch from dynamic memory to get it to the | 74 | /* We will allocate the latches from dynamic memory to get them to the |
217 | 72 | same DRAM page as other hotspot semaphores */ | 75 | same DRAM page as other hotspot semaphores */ |
219 | 73 | UNIV_INTERN rw_lock_t* btr_search_latch_temp; | 76 | UNIV_INTERN rw_lock_t** btr_search_latch_arr; |
220 | 74 | 77 | ||
221 | 75 | /** padding to prevent other memory update hotspots from residing on | 78 | /** padding to prevent other memory update hotspots from residing on |
222 | 76 | the same memory cache line */ | 79 | the same memory cache line */ |
223 | @@ -122,18 +125,19 @@ | |||
224 | 122 | will not guarantee success. */ | 125 | will not guarantee success. */ |
225 | 123 | static | 126 | static |
226 | 124 | void | 127 | void |
229 | 125 | btr_search_check_free_space_in_heap(void) | 128 | btr_search_check_free_space_in_heap( |
230 | 126 | /*=====================================*/ | 129 | /*================================*/ |
231 | 130 | index_id_t key) /*!<in: id of the hashed index tree */ | ||
232 | 127 | { | 131 | { |
233 | 128 | hash_table_t* table; | 132 | hash_table_t* table; |
234 | 129 | mem_heap_t* heap; | 133 | mem_heap_t* heap; |
235 | 130 | 134 | ||
236 | 131 | #ifdef UNIV_SYNC_DEBUG | 135 | #ifdef UNIV_SYNC_DEBUG |
239 | 132 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 136 | ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_SHARED)); |
240 | 133 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 137 | ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_EX)); |
241 | 134 | #endif /* UNIV_SYNC_DEBUG */ | 138 | #endif /* UNIV_SYNC_DEBUG */ |
242 | 135 | 139 | ||
244 | 136 | table = btr_search_sys->hash_index; | 140 | table = btr_search_get_hash_index(key); |
245 | 137 | 141 | ||
246 | 138 | heap = table->heap; | 142 | heap = table->heap; |
247 | 139 | 143 | ||
248 | @@ -144,7 +148,7 @@ | |||
249 | 144 | if (heap->free_block == NULL) { | 148 | if (heap->free_block == NULL) { |
250 | 145 | buf_block_t* block = buf_block_alloc(NULL); | 149 | buf_block_t* block = buf_block_alloc(NULL); |
251 | 146 | 150 | ||
253 | 147 | rw_lock_x_lock(&btr_search_latch); | 151 | rw_lock_x_lock(btr_search_get_latch(key)); |
254 | 148 | 152 | ||
255 | 149 | if (heap->free_block == NULL) { | 153 | if (heap->free_block == NULL) { |
256 | 150 | heap->free_block = block; | 154 | heap->free_block = block; |
257 | @@ -152,7 +156,7 @@ | |||
258 | 152 | buf_block_free(block); | 156 | buf_block_free(block); |
259 | 153 | } | 157 | } |
260 | 154 | 158 | ||
262 | 155 | rw_lock_x_unlock(&btr_search_latch); | 159 | rw_lock_x_unlock(btr_search_get_latch(key)); |
263 | 156 | } | 160 | } |
264 | 157 | } | 161 | } |
265 | 158 | 162 | ||
266 | @@ -164,23 +168,47 @@ | |||
267 | 164 | /*==================*/ | 168 | /*==================*/ |
268 | 165 | ulint hash_size) /*!< in: hash index hash table size */ | 169 | ulint hash_size) /*!< in: hash index hash table size */ |
269 | 166 | { | 170 | { |
270 | 171 | ulint i; | ||
271 | 172 | |||
272 | 173 | /* PS bug lp:1018264 - Multiple hash index partitions causes overly | ||
273 | 174 | large hash index: When multiple adaptive hash index partitions are | ||
274 | 175 | specified, _each_ partition was being created with hash_size which | ||
275 | 176 | should be 1/64 of the total size of all buffer pools which is | ||
276 | 177 | incorrect and can cause overly high memory usage. hash_size | ||
277 | 178 | should be representing the _total_ size of all partitions, not the | ||
278 | 179 | individual size of each partition. */ | ||
279 | 180 | hash_size /= btr_search_index_num; | ||
280 | 181 | |||
281 | 167 | /* We allocate the search latch from dynamic memory: | 182 | /* We allocate the search latch from dynamic memory: |
282 | 168 | see above at the global variable definition */ | 183 | see above at the global variable definition */ |
283 | 169 | 184 | ||
285 | 170 | btr_search_latch_temp = (rw_lock_t*) mem_alloc(sizeof(rw_lock_t)); | 185 | /* btr_search_index_num should be no greater than bits of |
286 | 186 | trx->has_search_latch, which is ulint. */ | ||
287 | 187 | ut_ad(btr_search_index_num <= sizeof(ulint)); | ||
288 | 171 | 188 | ||
291 | 172 | rw_lock_create(btr_search_latch_key, &btr_search_latch, | 189 | btr_search_latch_arr = (rw_lock_t**) |
292 | 173 | SYNC_SEARCH_SYS); | 190 | mem_alloc(sizeof(rw_lock_t *) * btr_search_index_num); |
293 | 174 | 191 | ||
294 | 175 | btr_search_sys = (btr_search_sys_t*) | 192 | btr_search_sys = (btr_search_sys_t*) |
295 | 176 | mem_alloc(sizeof(btr_search_sys_t)); | 193 | mem_alloc(sizeof(btr_search_sys_t)); |
296 | 177 | 194 | ||
299 | 178 | btr_search_sys->hash_index = ha_create(hash_size, 0, | 195 | btr_search_sys->hash_index = (hash_table_t **) |
300 | 179 | MEM_HEAP_FOR_BTR_SEARCH, 0); | 196 | mem_alloc(sizeof(hash_table_t *) * btr_search_index_num); |
301 | 197 | |||
302 | 198 | for (i = 0; i < btr_search_index_num; i++) { | ||
303 | 199 | btr_search_latch_arr[i] = (rw_lock_t *) | ||
304 | 200 | mem_alloc(sizeof(rw_lock_t)); | ||
305 | 201 | |||
306 | 202 | rw_lock_create(btr_search_latch_key, btr_search_latch_arr[i], | ||
307 | 203 | SYNC_SEARCH_SYS); | ||
308 | 204 | |||
309 | 205 | btr_search_sys->hash_index[i] | ||
310 | 206 | = ha_create(hash_size, 0, MEM_HEAP_FOR_BTR_SEARCH, 0); | ||
311 | 207 | |||
312 | 180 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG | 208 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG |
314 | 181 | btr_search_sys->hash_index->adaptive = TRUE; | 209 | btr_search_sys->hash_index[i]->adaptive = TRUE; |
315 | 182 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ | 210 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ |
317 | 183 | 211 | } | |
318 | 184 | } | 212 | } |
319 | 185 | 213 | ||
320 | 186 | /*****************************************************************//** | 214 | /*****************************************************************//** |
321 | @@ -190,11 +218,25 @@ | |||
322 | 190 | btr_search_sys_free(void) | 218 | btr_search_sys_free(void) |
323 | 191 | /*=====================*/ | 219 | /*=====================*/ |
324 | 192 | { | 220 | { |
330 | 193 | rw_lock_free(&btr_search_latch); | 221 | ulint i; |
331 | 194 | mem_free(btr_search_latch_temp); | 222 | |
332 | 195 | btr_search_latch_temp = NULL; | 223 | for (i = 0; i < btr_search_index_num; i++) { |
333 | 196 | mem_heap_free(btr_search_sys->hash_index->heap); | 224 | |
334 | 197 | hash_table_free(btr_search_sys->hash_index); | 225 | rw_lock_free(btr_search_latch_arr[i]); |
335 | 226 | |||
336 | 227 | mem_free(btr_search_latch_arr[i]); | ||
337 | 228 | |||
338 | 229 | mem_heap_free(btr_search_sys->hash_index[i]->heap); | ||
339 | 230 | |||
340 | 231 | hash_table_free(btr_search_sys->hash_index[i]); | ||
341 | 232 | |||
342 | 233 | } | ||
343 | 234 | |||
344 | 235 | mem_free(btr_search_latch_arr); | ||
345 | 236 | btr_search_latch_arr = NULL; | ||
346 | 237 | |||
347 | 238 | mem_free(btr_search_sys->hash_index); | ||
348 | 239 | |||
349 | 198 | mem_free(btr_search_sys); | 240 | mem_free(btr_search_sys); |
350 | 199 | btr_search_sys = NULL; | 241 | btr_search_sys = NULL; |
351 | 200 | } | 242 | } |
352 | @@ -210,13 +252,14 @@ | |||
353 | 210 | dict_index_t* index; | 252 | dict_index_t* index; |
354 | 211 | 253 | ||
355 | 212 | ut_ad(mutex_own(&dict_sys->mutex)); | 254 | ut_ad(mutex_own(&dict_sys->mutex)); |
356 | 213 | #ifdef UNIV_SYNC_DEBUG | ||
357 | 214 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | ||
358 | 215 | #endif /* UNIV_SYNC_DEBUG */ | ||
359 | 216 | 255 | ||
360 | 217 | for (index = dict_table_get_first_index(table); index; | 256 | for (index = dict_table_get_first_index(table); index; |
361 | 218 | index = dict_table_get_next_index(index)) { | 257 | index = dict_table_get_next_index(index)) { |
362 | 219 | 258 | ||
363 | 259 | #ifdef UNIV_SYNC_DEBUG | ||
364 | 260 | ut_ad(rw_lock_own(btr_search_get_latch(index->id), | ||
365 | 261 | RW_LOCK_EX)); | ||
366 | 262 | #endif /* UNIV_SYNC_DEBUG */ | ||
367 | 220 | index->search_info->ref_count = 0; | 263 | index->search_info->ref_count = 0; |
368 | 221 | } | 264 | } |
369 | 222 | } | 265 | } |
370 | @@ -229,9 +272,10 @@ | |||
371 | 229 | /*====================*/ | 272 | /*====================*/ |
372 | 230 | { | 273 | { |
373 | 231 | dict_table_t* table; | 274 | dict_table_t* table; |
374 | 275 | ulint i; | ||
375 | 232 | 276 | ||
376 | 233 | mutex_enter(&dict_sys->mutex); | 277 | mutex_enter(&dict_sys->mutex); |
378 | 234 | rw_lock_x_lock(&btr_search_latch); | 278 | btr_search_x_lock_all(); |
379 | 235 | 279 | ||
380 | 236 | btr_search_enabled = FALSE; | 280 | btr_search_enabled = FALSE; |
381 | 237 | 281 | ||
382 | @@ -255,10 +299,12 @@ | |||
383 | 255 | buf_pool_clear_hash_index(); | 299 | buf_pool_clear_hash_index(); |
384 | 256 | 300 | ||
385 | 257 | /* Clear the adaptive hash index. */ | 301 | /* Clear the adaptive hash index. */ |
388 | 258 | hash_table_clear(btr_search_sys->hash_index); | 302 | for (i = 0; i < btr_search_index_num; i++) { |
389 | 259 | mem_heap_empty(btr_search_sys->hash_index->heap); | 303 | hash_table_clear(btr_search_sys->hash_index[i]); |
390 | 304 | mem_heap_empty(btr_search_sys->hash_index[i]->heap); | ||
391 | 305 | } | ||
392 | 260 | 306 | ||
394 | 261 | rw_lock_x_unlock(&btr_search_latch); | 307 | btr_search_x_unlock_all(); |
395 | 262 | } | 308 | } |
396 | 263 | 309 | ||
397 | 264 | /********************************************************************//** | 310 | /********************************************************************//** |
398 | @@ -268,11 +314,11 @@ | |||
399 | 268 | btr_search_enable(void) | 314 | btr_search_enable(void) |
400 | 269 | /*====================*/ | 315 | /*====================*/ |
401 | 270 | { | 316 | { |
403 | 271 | rw_lock_x_lock(&btr_search_latch); | 317 | btr_search_x_lock_all(); |
404 | 272 | 318 | ||
405 | 273 | btr_search_enabled = TRUE; | 319 | btr_search_enabled = TRUE; |
406 | 274 | 320 | ||
408 | 275 | rw_lock_x_unlock(&btr_search_latch); | 321 | btr_search_x_unlock_all(); |
409 | 276 | } | 322 | } |
410 | 277 | 323 | ||
411 | 278 | /*****************************************************************//** | 324 | /*****************************************************************//** |
412 | @@ -324,20 +370,21 @@ | |||
413 | 324 | ulint | 370 | ulint |
414 | 325 | btr_search_info_get_ref_count( | 371 | btr_search_info_get_ref_count( |
415 | 326 | /*==========================*/ | 372 | /*==========================*/ |
417 | 327 | btr_search_t* info) /*!< in: search info. */ | 373 | btr_search_t* info, /*!< in: search info. */ |
418 | 374 | index_id_t key) /*!< in: id of the index owning search info */ | ||
419 | 328 | { | 375 | { |
420 | 329 | ulint ret; | 376 | ulint ret; |
421 | 330 | 377 | ||
422 | 331 | ut_ad(info); | 378 | ut_ad(info); |
423 | 332 | 379 | ||
424 | 333 | #ifdef UNIV_SYNC_DEBUG | 380 | #ifdef UNIV_SYNC_DEBUG |
427 | 334 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 381 | ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_SHARED)); |
428 | 335 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 382 | ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_EX)); |
429 | 336 | #endif /* UNIV_SYNC_DEBUG */ | 383 | #endif /* UNIV_SYNC_DEBUG */ |
430 | 337 | 384 | ||
432 | 338 | rw_lock_s_lock(&btr_search_latch); | 385 | rw_lock_s_lock(btr_search_get_latch(key)); |
433 | 339 | ret = info->ref_count; | 386 | ret = info->ref_count; |
435 | 340 | rw_lock_s_unlock(&btr_search_latch); | 387 | rw_lock_s_unlock(btr_search_get_latch(key)); |
436 | 341 | 388 | ||
437 | 342 | return(ret); | 389 | return(ret); |
438 | 343 | } | 390 | } |
439 | @@ -353,17 +400,15 @@ | |||
440 | 353 | btr_search_t* info, /*!< in/out: search info */ | 400 | btr_search_t* info, /*!< in/out: search info */ |
441 | 354 | btr_cur_t* cursor) /*!< in: cursor which was just positioned */ | 401 | btr_cur_t* cursor) /*!< in: cursor which was just positioned */ |
442 | 355 | { | 402 | { |
444 | 356 | dict_index_t* index; | 403 | dict_index_t* index = cursor->index; |
445 | 357 | ulint n_unique; | 404 | ulint n_unique; |
446 | 358 | int cmp; | 405 | int cmp; |
447 | 359 | 406 | ||
448 | 360 | #ifdef UNIV_SYNC_DEBUG | 407 | #ifdef UNIV_SYNC_DEBUG |
451 | 361 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 408 | ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_SHARED)); |
452 | 362 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 409 | ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_EX)); |
453 | 363 | #endif /* UNIV_SYNC_DEBUG */ | 410 | #endif /* UNIV_SYNC_DEBUG */ |
454 | 364 | 411 | ||
455 | 365 | index = cursor->index; | ||
456 | 366 | |||
457 | 367 | if (dict_index_is_ibuf(index)) { | 412 | if (dict_index_is_ibuf(index)) { |
458 | 368 | /* So many deletes are performed on an insert buffer tree | 413 | /* So many deletes are performed on an insert buffer tree |
459 | 369 | that we do not consider a hash index useful on it: */ | 414 | that we do not consider a hash index useful on it: */ |
460 | @@ -477,8 +522,10 @@ | |||
461 | 477 | /*!< in: cursor */ | 522 | /*!< in: cursor */ |
462 | 478 | { | 523 | { |
463 | 479 | #ifdef UNIV_SYNC_DEBUG | 524 | #ifdef UNIV_SYNC_DEBUG |
466 | 480 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 525 | ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), |
467 | 481 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 526 | RW_LOCK_SHARED)); |
468 | 527 | ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), | ||
469 | 528 | RW_LOCK_EX)); | ||
470 | 482 | ut_ad(rw_lock_own(&block->lock, RW_LOCK_SHARED) | 529 | ut_ad(rw_lock_own(&block->lock, RW_LOCK_SHARED) |
471 | 483 | || rw_lock_own(&block->lock, RW_LOCK_EX)); | 530 | || rw_lock_own(&block->lock, RW_LOCK_EX)); |
472 | 484 | #endif /* UNIV_SYNC_DEBUG */ | 531 | #endif /* UNIV_SYNC_DEBUG */ |
473 | @@ -562,7 +609,8 @@ | |||
474 | 562 | 609 | ||
475 | 563 | ut_ad(cursor->flag == BTR_CUR_HASH_FAIL); | 610 | ut_ad(cursor->flag == BTR_CUR_HASH_FAIL); |
476 | 564 | #ifdef UNIV_SYNC_DEBUG | 611 | #ifdef UNIV_SYNC_DEBUG |
478 | 565 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 612 | ut_ad(rw_lock_own(btr_search_get_latch(cursor->index->id), |
479 | 613 | RW_LOCK_EX)); | ||
480 | 566 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) | 614 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) |
481 | 567 | || rw_lock_own(&(block->lock), RW_LOCK_EX)); | 615 | || rw_lock_own(&(block->lock), RW_LOCK_EX)); |
482 | 568 | #endif /* UNIV_SYNC_DEBUG */ | 616 | #endif /* UNIV_SYNC_DEBUG */ |
483 | @@ -603,11 +651,13 @@ | |||
484 | 603 | mem_heap_free(heap); | 651 | mem_heap_free(heap); |
485 | 604 | } | 652 | } |
486 | 605 | #ifdef UNIV_SYNC_DEBUG | 653 | #ifdef UNIV_SYNC_DEBUG |
488 | 606 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 654 | ut_ad(rw_lock_own(btr_search_get_latch(cursor->index->id), |
489 | 655 | RW_LOCK_EX)); | ||
490 | 607 | #endif /* UNIV_SYNC_DEBUG */ | 656 | #endif /* UNIV_SYNC_DEBUG */ |
491 | 608 | 657 | ||
494 | 609 | ha_insert_for_fold(btr_search_sys->hash_index, fold, | 658 | ha_insert_for_fold( |
495 | 610 | block, rec); | 659 | btr_search_get_hash_index(cursor->index->id), fold, |
496 | 660 | block, rec); | ||
497 | 611 | 661 | ||
498 | 612 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_ROW_ADDED); | 662 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_ROW_ADDED); |
499 | 613 | } | 663 | } |
500 | @@ -628,8 +678,10 @@ | |||
501 | 628 | ulint* params2; | 678 | ulint* params2; |
502 | 629 | 679 | ||
503 | 630 | #ifdef UNIV_SYNC_DEBUG | 680 | #ifdef UNIV_SYNC_DEBUG |
506 | 631 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 681 | ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), |
507 | 632 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 682 | RW_LOCK_SHARED)); |
508 | 683 | ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), | ||
509 | 684 | RW_LOCK_EX)); | ||
510 | 633 | #endif /* UNIV_SYNC_DEBUG */ | 685 | #endif /* UNIV_SYNC_DEBUG */ |
511 | 634 | 686 | ||
512 | 635 | block = btr_cur_get_block(cursor); | 687 | block = btr_cur_get_block(cursor); |
513 | @@ -647,7 +699,7 @@ | |||
514 | 647 | 699 | ||
515 | 648 | if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) { | 700 | if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) { |
516 | 649 | 701 | ||
518 | 650 | btr_search_check_free_space_in_heap(); | 702 | btr_search_check_free_space_in_heap(cursor->index->id); |
519 | 651 | } | 703 | } |
520 | 652 | 704 | ||
521 | 653 | if (cursor->flag == BTR_CUR_HASH_FAIL) { | 705 | if (cursor->flag == BTR_CUR_HASH_FAIL) { |
522 | @@ -657,11 +709,11 @@ | |||
523 | 657 | btr_search_n_hash_fail++; | 709 | btr_search_n_hash_fail++; |
524 | 658 | #endif /* UNIV_SEARCH_PERF_STAT */ | 710 | #endif /* UNIV_SEARCH_PERF_STAT */ |
525 | 659 | 711 | ||
527 | 660 | rw_lock_x_lock(&btr_search_latch); | 712 | rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); |
528 | 661 | 713 | ||
529 | 662 | btr_search_update_hash_ref(info, block, cursor); | 714 | btr_search_update_hash_ref(info, block, cursor); |
530 | 663 | 715 | ||
532 | 664 | rw_lock_x_unlock(&btr_search_latch); | 716 | rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); |
533 | 665 | } | 717 | } |
534 | 666 | 718 | ||
535 | 667 | if (build_index) { | 719 | if (build_index) { |
536 | @@ -906,17 +958,19 @@ | |||
537 | 906 | cursor->flag = BTR_CUR_HASH; | 958 | cursor->flag = BTR_CUR_HASH; |
538 | 907 | 959 | ||
539 | 908 | if (UNIV_LIKELY(!has_search_latch)) { | 960 | if (UNIV_LIKELY(!has_search_latch)) { |
541 | 909 | rw_lock_s_lock(&btr_search_latch); | 961 | rw_lock_s_lock(btr_search_get_latch(index_id)); |
542 | 910 | 962 | ||
543 | 911 | if (UNIV_UNLIKELY(!btr_search_enabled)) { | 963 | if (UNIV_UNLIKELY(!btr_search_enabled)) { |
544 | 912 | goto failure_unlock; | 964 | goto failure_unlock; |
545 | 913 | } | 965 | } |
546 | 914 | } | 966 | } |
547 | 915 | 967 | ||
550 | 916 | ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX); | 968 | ut_ad(rw_lock_get_writer(btr_search_get_latch(index_id)) |
551 | 917 | ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0); | 969 | != RW_LOCK_EX); |
552 | 970 | ut_ad(rw_lock_get_reader_count(btr_search_get_latch(index_id)) > 0); | ||
553 | 918 | 971 | ||
555 | 919 | rec = (rec_t*) ha_search_and_get_data(btr_search_sys->hash_index, fold); | 972 | rec = (rec_t*) ha_search_and_get_data( |
556 | 973 | btr_search_get_hash_index(index_id), fold); | ||
557 | 920 | 974 | ||
558 | 921 | if (UNIV_UNLIKELY(!rec)) { | 975 | if (UNIV_UNLIKELY(!rec)) { |
559 | 922 | goto failure_unlock; | 976 | goto failure_unlock; |
560 | @@ -934,7 +988,7 @@ | |||
561 | 934 | goto failure_unlock; | 988 | goto failure_unlock; |
562 | 935 | } | 989 | } |
563 | 936 | 990 | ||
565 | 937 | rw_lock_s_unlock(&btr_search_latch); | 991 | rw_lock_s_unlock(btr_search_get_latch(index_id)); |
566 | 938 | 992 | ||
567 | 939 | buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH); | 993 | buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH); |
568 | 940 | } | 994 | } |
569 | @@ -1031,7 +1085,7 @@ | |||
570 | 1031 | /*-------------------------------------------*/ | 1085 | /*-------------------------------------------*/ |
571 | 1032 | failure_unlock: | 1086 | failure_unlock: |
572 | 1033 | if (UNIV_LIKELY(!has_search_latch)) { | 1087 | if (UNIV_LIKELY(!has_search_latch)) { |
574 | 1034 | rw_lock_s_unlock(&btr_search_latch); | 1088 | rw_lock_s_unlock(btr_search_get_latch(index_id)); |
575 | 1035 | } | 1089 | } |
576 | 1036 | failure: | 1090 | failure: |
577 | 1037 | cursor->flag = BTR_CUR_HASH_FAIL; | 1091 | cursor->flag = BTR_CUR_HASH_FAIL; |
578 | @@ -1079,12 +1133,9 @@ | |||
579 | 1079 | const dict_index_t* index; | 1133 | const dict_index_t* index; |
580 | 1080 | ulint* offsets; | 1134 | ulint* offsets; |
581 | 1081 | btr_search_t* info; | 1135 | btr_search_t* info; |
588 | 1082 | 1136 | rw_lock_t* btr_search_latch; | |
589 | 1083 | #ifdef UNIV_SYNC_DEBUG | 1137 | |
590 | 1084 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 1138 | retry: |
585 | 1085 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | ||
586 | 1086 | #endif /* UNIV_SYNC_DEBUG */ | ||
587 | 1087 | |||
591 | 1088 | /* Do a dirty check on block->index, return if the block is | 1139 | /* Do a dirty check on block->index, return if the block is |
592 | 1089 | not in the adaptive hash index. This is to avoid acquiring | 1140 | not in the adaptive hash index. This is to avoid acquiring |
593 | 1090 | shared btr_search_latch for performance consideration. */ | 1141 | shared btr_search_latch for performance consideration. */ |
594 | @@ -1092,17 +1143,31 @@ | |||
595 | 1092 | return; | 1143 | return; |
596 | 1093 | } | 1144 | } |
597 | 1094 | 1145 | ||
600 | 1095 | retry: | 1146 | btr_search_latch = block->btr_search_latch; |
601 | 1096 | rw_lock_s_lock(&btr_search_latch); | 1147 | |
602 | 1148 | if (UNIV_UNLIKELY(!btr_search_latch)) { | ||
603 | 1149 | return; | ||
604 | 1150 | } | ||
605 | 1151 | |||
606 | 1152 | #ifdef UNIV_SYNC_DEBUG | ||
607 | 1153 | ut_ad(!rw_lock_own(btr_search_latch, RW_LOCK_SHARED)); | ||
608 | 1154 | ut_ad(!rw_lock_own(btr_search_latch, RW_LOCK_EX)); | ||
609 | 1155 | #endif /* UNIV_SYNC_DEBUG */ | ||
610 | 1156 | |||
611 | 1157 | rw_lock_s_lock(btr_search_latch); | ||
612 | 1158 | if (UNIV_UNLIKELY(btr_search_latch != block->btr_search_latch)) { | ||
613 | 1159 | rw_lock_s_unlock(btr_search_latch); | ||
614 | 1160 | goto retry; | ||
615 | 1161 | } | ||
616 | 1162 | |||
617 | 1097 | index = block->index; | 1163 | index = block->index; |
623 | 1098 | 1164 | if (UNIV_UNLIKELY(!index)) { | |
624 | 1099 | if (UNIV_LIKELY(!index)) { | 1165 | rw_lock_s_unlock(btr_search_latch); |
620 | 1100 | |||
621 | 1101 | rw_lock_s_unlock(&btr_search_latch); | ||
622 | 1102 | |||
625 | 1103 | return; | 1166 | return; |
626 | 1104 | } | 1167 | } |
627 | 1105 | 1168 | ||
628 | 1169 | ut_ad(btr_search_latch == btr_search_get_latch(index->id)); | ||
629 | 1170 | |||
630 | 1106 | ut_a(!dict_index_is_ibuf(index)); | 1171 | ut_a(!dict_index_is_ibuf(index)); |
631 | 1107 | #ifdef UNIV_DEBUG | 1172 | #ifdef UNIV_DEBUG |
632 | 1108 | switch (dict_index_get_online_status(index)) { | 1173 | switch (dict_index_get_online_status(index)) { |
633 | @@ -1125,7 +1190,7 @@ | |||
634 | 1125 | } | 1190 | } |
635 | 1126 | #endif /* UNIV_DEBUG */ | 1191 | #endif /* UNIV_DEBUG */ |
636 | 1127 | 1192 | ||
638 | 1128 | table = btr_search_sys->hash_index; | 1193 | table = btr_search_get_hash_index(index->id); |
639 | 1129 | 1194 | ||
640 | 1130 | #ifdef UNIV_SYNC_DEBUG | 1195 | #ifdef UNIV_SYNC_DEBUG |
641 | 1131 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) | 1196 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) |
642 | @@ -1141,7 +1206,7 @@ | |||
643 | 1141 | releasing btr_search_latch, as the index page might only | 1206 | releasing btr_search_latch, as the index page might only |
644 | 1142 | be s-latched! */ | 1207 | be s-latched! */ |
645 | 1143 | 1208 | ||
647 | 1144 | rw_lock_s_unlock(&btr_search_latch); | 1209 | rw_lock_s_unlock(btr_search_latch); |
648 | 1145 | 1210 | ||
649 | 1146 | ut_a(n_fields + n_bytes > 0); | 1211 | ut_a(n_fields + n_bytes > 0); |
650 | 1147 | 1212 | ||
651 | @@ -1192,7 +1257,7 @@ | |||
652 | 1192 | mem_heap_free(heap); | 1257 | mem_heap_free(heap); |
653 | 1193 | } | 1258 | } |
654 | 1194 | 1259 | ||
656 | 1195 | rw_lock_x_lock(&btr_search_latch); | 1260 | rw_lock_x_lock(btr_search_get_latch(index->id)); |
657 | 1196 | 1261 | ||
658 | 1197 | if (UNIV_UNLIKELY(!block->index)) { | 1262 | if (UNIV_UNLIKELY(!block->index)) { |
659 | 1198 | /* Someone else has meanwhile dropped the hash index */ | 1263 | /* Someone else has meanwhile dropped the hash index */ |
660 | @@ -1208,7 +1273,7 @@ | |||
661 | 1208 | /* Someone else has meanwhile built a new hash index on the | 1273 | /* Someone else has meanwhile built a new hash index on the |
662 | 1209 | page, with different parameters */ | 1274 | page, with different parameters */ |
663 | 1210 | 1275 | ||
665 | 1211 | rw_lock_x_unlock(&btr_search_latch); | 1276 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
666 | 1212 | 1277 | ||
667 | 1213 | mem_free(folds); | 1278 | mem_free(folds); |
668 | 1214 | goto retry; | 1279 | goto retry; |
669 | @@ -1224,6 +1289,7 @@ | |||
670 | 1224 | info->ref_count--; | 1289 | info->ref_count--; |
671 | 1225 | 1290 | ||
672 | 1226 | block->index = NULL; | 1291 | block->index = NULL; |
673 | 1292 | block->btr_search_latch = NULL; | ||
674 | 1227 | 1293 | ||
675 | 1228 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_REMOVED); | 1294 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_REMOVED); |
676 | 1229 | MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_REMOVED, n_cached); | 1295 | MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_REMOVED, n_cached); |
677 | @@ -1239,14 +1305,14 @@ | |||
678 | 1239 | "InnoDB: the hash index to a page of %s," | 1305 | "InnoDB: the hash index to a page of %s," |
679 | 1240 | " still %lu hash nodes remain.\n", | 1306 | " still %lu hash nodes remain.\n", |
680 | 1241 | index->name, (ulong) block->n_pointers); | 1307 | index->name, (ulong) block->n_pointers); |
682 | 1242 | rw_lock_x_unlock(&btr_search_latch); | 1308 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
683 | 1243 | 1309 | ||
684 | 1244 | ut_ad(btr_search_validate()); | 1310 | ut_ad(btr_search_validate()); |
685 | 1245 | } else { | 1311 | } else { |
687 | 1246 | rw_lock_x_unlock(&btr_search_latch); | 1312 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
688 | 1247 | } | 1313 | } |
689 | 1248 | #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */ | 1314 | #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */ |
691 | 1249 | rw_lock_x_unlock(&btr_search_latch); | 1315 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
692 | 1250 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ | 1316 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ |
693 | 1251 | 1317 | ||
694 | 1252 | mem_free(folds); | 1318 | mem_free(folds); |
695 | @@ -1325,30 +1391,30 @@ | |||
696 | 1325 | ut_a(!dict_index_is_ibuf(index)); | 1391 | ut_a(!dict_index_is_ibuf(index)); |
697 | 1326 | 1392 | ||
698 | 1327 | #ifdef UNIV_SYNC_DEBUG | 1393 | #ifdef UNIV_SYNC_DEBUG |
700 | 1328 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 1394 | ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_EX)); |
701 | 1329 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) | 1395 | ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) |
702 | 1330 | || rw_lock_own(&(block->lock), RW_LOCK_EX)); | 1396 | || rw_lock_own(&(block->lock), RW_LOCK_EX)); |
703 | 1331 | #endif /* UNIV_SYNC_DEBUG */ | 1397 | #endif /* UNIV_SYNC_DEBUG */ |
704 | 1332 | 1398 | ||
706 | 1333 | rw_lock_s_lock(&btr_search_latch); | 1399 | rw_lock_s_lock(btr_search_get_latch(index->id)); |
707 | 1334 | 1400 | ||
708 | 1335 | if (!btr_search_enabled) { | 1401 | if (!btr_search_enabled) { |
710 | 1336 | rw_lock_s_unlock(&btr_search_latch); | 1402 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
711 | 1337 | return; | 1403 | return; |
712 | 1338 | } | 1404 | } |
713 | 1339 | 1405 | ||
715 | 1340 | table = btr_search_sys->hash_index; | 1406 | table = btr_search_get_hash_index(index->id); |
716 | 1341 | page = buf_block_get_frame(block); | 1407 | page = buf_block_get_frame(block); |
717 | 1342 | 1408 | ||
718 | 1343 | if (block->index && ((block->curr_n_fields != n_fields) | 1409 | if (block->index && ((block->curr_n_fields != n_fields) |
719 | 1344 | || (block->curr_n_bytes != n_bytes) | 1410 | || (block->curr_n_bytes != n_bytes) |
720 | 1345 | || (block->curr_left_side != left_side))) { | 1411 | || (block->curr_left_side != left_side))) { |
721 | 1346 | 1412 | ||
723 | 1347 | rw_lock_s_unlock(&btr_search_latch); | 1413 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
724 | 1348 | 1414 | ||
725 | 1349 | btr_search_drop_page_hash_index(block); | 1415 | btr_search_drop_page_hash_index(block); |
726 | 1350 | } else { | 1416 | } else { |
728 | 1351 | rw_lock_s_unlock(&btr_search_latch); | 1417 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
729 | 1352 | } | 1418 | } |
730 | 1353 | 1419 | ||
731 | 1354 | n_recs = page_get_n_recs(page); | 1420 | n_recs = page_get_n_recs(page); |
732 | @@ -1442,9 +1508,9 @@ | |||
733 | 1442 | fold = next_fold; | 1508 | fold = next_fold; |
734 | 1443 | } | 1509 | } |
735 | 1444 | 1510 | ||
737 | 1445 | btr_search_check_free_space_in_heap(); | 1511 | btr_search_check_free_space_in_heap(index->id); |
738 | 1446 | 1512 | ||
740 | 1447 | rw_lock_x_lock(&btr_search_latch); | 1513 | rw_lock_x_lock(btr_search_get_latch(index->id)); |
741 | 1448 | 1514 | ||
742 | 1449 | if (UNIV_UNLIKELY(!btr_search_enabled)) { | 1515 | if (UNIV_UNLIKELY(!btr_search_enabled)) { |
743 | 1450 | goto exit_func; | 1516 | goto exit_func; |
744 | @@ -1471,6 +1537,7 @@ | |||
745 | 1471 | block->curr_n_bytes = n_bytes; | 1537 | block->curr_n_bytes = n_bytes; |
746 | 1472 | block->curr_left_side = left_side; | 1538 | block->curr_left_side = left_side; |
747 | 1473 | block->index = index; | 1539 | block->index = index; |
748 | 1540 | block->btr_search_latch = btr_search_get_latch(index->id); | ||
749 | 1474 | 1541 | ||
750 | 1475 | for (i = 0; i < n_cached; i++) { | 1542 | for (i = 0; i < n_cached; i++) { |
751 | 1476 | 1543 | ||
752 | @@ -1480,7 +1547,7 @@ | |||
753 | 1480 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_ADDED); | 1547 | MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_ADDED); |
754 | 1481 | MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_ADDED, n_cached); | 1548 | MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_ADDED, n_cached); |
755 | 1482 | exit_func: | 1549 | exit_func: |
757 | 1483 | rw_lock_x_unlock(&btr_search_latch); | 1550 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
758 | 1484 | 1551 | ||
759 | 1485 | mem_free(folds); | 1552 | mem_free(folds); |
760 | 1486 | mem_free(recs); | 1553 | mem_free(recs); |
761 | @@ -1515,7 +1582,7 @@ | |||
762 | 1515 | ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX)); | 1582 | ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX)); |
763 | 1516 | #endif /* UNIV_SYNC_DEBUG */ | 1583 | #endif /* UNIV_SYNC_DEBUG */ |
764 | 1517 | 1584 | ||
766 | 1518 | rw_lock_s_lock(&btr_search_latch); | 1585 | rw_lock_s_lock(btr_search_get_latch(index->id)); |
767 | 1519 | 1586 | ||
768 | 1520 | ut_a(!new_block->index || new_block->index == index); | 1587 | ut_a(!new_block->index || new_block->index == index); |
769 | 1521 | ut_a(!block->index || block->index == index); | 1588 | ut_a(!block->index || block->index == index); |
770 | @@ -1524,7 +1591,7 @@ | |||
771 | 1524 | 1591 | ||
772 | 1525 | if (new_block->index) { | 1592 | if (new_block->index) { |
773 | 1526 | 1593 | ||
775 | 1527 | rw_lock_s_unlock(&btr_search_latch); | 1594 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
776 | 1528 | 1595 | ||
777 | 1529 | btr_search_drop_page_hash_index(block); | 1596 | btr_search_drop_page_hash_index(block); |
778 | 1530 | 1597 | ||
779 | @@ -1541,7 +1608,7 @@ | |||
780 | 1541 | new_block->n_bytes = block->curr_n_bytes; | 1608 | new_block->n_bytes = block->curr_n_bytes; |
781 | 1542 | new_block->left_side = left_side; | 1609 | new_block->left_side = left_side; |
782 | 1543 | 1610 | ||
784 | 1544 | rw_lock_s_unlock(&btr_search_latch); | 1611 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
785 | 1545 | 1612 | ||
786 | 1546 | ut_a(n_fields + n_bytes > 0); | 1613 | ut_a(n_fields + n_bytes > 0); |
787 | 1547 | 1614 | ||
788 | @@ -1553,7 +1620,7 @@ | |||
789 | 1553 | return; | 1620 | return; |
790 | 1554 | } | 1621 | } |
791 | 1555 | 1622 | ||
793 | 1556 | rw_lock_s_unlock(&btr_search_latch); | 1623 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
794 | 1557 | } | 1624 | } |
795 | 1558 | 1625 | ||
796 | 1559 | /********************************************************************//** | 1626 | /********************************************************************//** |
797 | @@ -1592,7 +1659,7 @@ | |||
798 | 1592 | ut_a(block->curr_n_fields + block->curr_n_bytes > 0); | 1659 | ut_a(block->curr_n_fields + block->curr_n_bytes > 0); |
799 | 1593 | ut_a(!dict_index_is_ibuf(index)); | 1660 | ut_a(!dict_index_is_ibuf(index)); |
800 | 1594 | 1661 | ||
802 | 1595 | table = btr_search_sys->hash_index; | 1662 | table = btr_search_get_hash_index(cursor->index->id); |
803 | 1596 | 1663 | ||
804 | 1597 | rec = btr_cur_get_rec(cursor); | 1664 | rec = btr_cur_get_rec(cursor); |
805 | 1598 | 1665 | ||
806 | @@ -1603,7 +1670,7 @@ | |||
807 | 1603 | mem_heap_free(heap); | 1670 | mem_heap_free(heap); |
808 | 1604 | } | 1671 | } |
809 | 1605 | 1672 | ||
811 | 1606 | rw_lock_x_lock(&btr_search_latch); | 1673 | rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); |
812 | 1607 | 1674 | ||
813 | 1608 | if (block->index) { | 1675 | if (block->index) { |
814 | 1609 | ut_a(block->index == index); | 1676 | ut_a(block->index == index); |
815 | @@ -1616,7 +1683,7 @@ | |||
816 | 1616 | } | 1683 | } |
817 | 1617 | } | 1684 | } |
818 | 1618 | 1685 | ||
820 | 1619 | rw_lock_x_unlock(&btr_search_latch); | 1686 | rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); |
821 | 1620 | } | 1687 | } |
822 | 1621 | 1688 | ||
823 | 1622 | /********************************************************************//** | 1689 | /********************************************************************//** |
824 | @@ -1653,7 +1720,7 @@ | |||
825 | 1653 | ut_a(cursor->index == index); | 1720 | ut_a(cursor->index == index); |
826 | 1654 | ut_a(!dict_index_is_ibuf(index)); | 1721 | ut_a(!dict_index_is_ibuf(index)); |
827 | 1655 | 1722 | ||
829 | 1656 | rw_lock_x_lock(&btr_search_latch); | 1723 | rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); |
830 | 1657 | 1724 | ||
831 | 1658 | if (!block->index) { | 1725 | if (!block->index) { |
832 | 1659 | 1726 | ||
833 | @@ -1667,7 +1734,7 @@ | |||
834 | 1667 | && (cursor->n_bytes == block->curr_n_bytes) | 1734 | && (cursor->n_bytes == block->curr_n_bytes) |
835 | 1668 | && !block->curr_left_side) { | 1735 | && !block->curr_left_side) { |
836 | 1669 | 1736 | ||
838 | 1670 | table = btr_search_sys->hash_index; | 1737 | table = btr_search_get_hash_index(cursor->index->id); |
839 | 1671 | 1738 | ||
840 | 1672 | if (ha_search_and_update_if_found( | 1739 | if (ha_search_and_update_if_found( |
841 | 1673 | table, cursor->fold, rec, block, | 1740 | table, cursor->fold, rec, block, |
842 | @@ -1676,9 +1743,9 @@ | |||
843 | 1676 | } | 1743 | } |
844 | 1677 | 1744 | ||
845 | 1678 | func_exit: | 1745 | func_exit: |
847 | 1679 | rw_lock_x_unlock(&btr_search_latch); | 1746 | rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); |
848 | 1680 | } else { | 1747 | } else { |
850 | 1681 | rw_lock_x_unlock(&btr_search_latch); | 1748 | rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); |
851 | 1682 | 1749 | ||
852 | 1683 | btr_search_update_hash_on_insert(cursor); | 1750 | btr_search_update_hash_on_insert(cursor); |
853 | 1684 | } | 1751 | } |
854 | @@ -1726,9 +1793,9 @@ | |||
855 | 1726 | return; | 1793 | return; |
856 | 1727 | } | 1794 | } |
857 | 1728 | 1795 | ||
859 | 1729 | btr_search_check_free_space_in_heap(); | 1796 | btr_search_check_free_space_in_heap(cursor->index->id); |
860 | 1730 | 1797 | ||
862 | 1731 | table = btr_search_sys->hash_index; | 1798 | table = btr_search_get_hash_index(cursor->index->id); |
863 | 1732 | 1799 | ||
864 | 1733 | rec = btr_cur_get_rec(cursor); | 1800 | rec = btr_cur_get_rec(cursor); |
865 | 1734 | 1801 | ||
866 | @@ -1760,7 +1827,7 @@ | |||
867 | 1760 | } else { | 1827 | } else { |
868 | 1761 | if (left_side) { | 1828 | if (left_side) { |
869 | 1762 | 1829 | ||
871 | 1763 | rw_lock_x_lock(&btr_search_latch); | 1830 | rw_lock_x_lock(btr_search_get_latch(index->id)); |
872 | 1764 | 1831 | ||
873 | 1765 | locked = TRUE; | 1832 | locked = TRUE; |
874 | 1766 | 1833 | ||
875 | @@ -1778,7 +1845,7 @@ | |||
876 | 1778 | 1845 | ||
877 | 1779 | if (!locked) { | 1846 | if (!locked) { |
878 | 1780 | 1847 | ||
880 | 1781 | rw_lock_x_lock(&btr_search_latch); | 1848 | rw_lock_x_lock(btr_search_get_latch(index->id)); |
881 | 1782 | 1849 | ||
882 | 1783 | locked = TRUE; | 1850 | locked = TRUE; |
883 | 1784 | 1851 | ||
884 | @@ -1800,7 +1867,8 @@ | |||
885 | 1800 | if (!left_side) { | 1867 | if (!left_side) { |
886 | 1801 | 1868 | ||
887 | 1802 | if (!locked) { | 1869 | if (!locked) { |
889 | 1803 | rw_lock_x_lock(&btr_search_latch); | 1870 | rw_lock_x_lock(btr_search_get_latch( |
890 | 1871 | index->id)); | ||
891 | 1804 | 1872 | ||
892 | 1805 | locked = TRUE; | 1873 | locked = TRUE; |
893 | 1806 | 1874 | ||
894 | @@ -1819,7 +1887,7 @@ | |||
895 | 1819 | 1887 | ||
896 | 1820 | if (!locked) { | 1888 | if (!locked) { |
897 | 1821 | 1889 | ||
899 | 1822 | rw_lock_x_lock(&btr_search_latch); | 1890 | rw_lock_x_lock(btr_search_get_latch(index->id)); |
900 | 1823 | 1891 | ||
901 | 1824 | locked = TRUE; | 1892 | locked = TRUE; |
902 | 1825 | 1893 | ||
903 | @@ -1846,18 +1914,19 @@ | |||
904 | 1846 | mem_heap_free(heap); | 1914 | mem_heap_free(heap); |
905 | 1847 | } | 1915 | } |
906 | 1848 | if (locked) { | 1916 | if (locked) { |
908 | 1849 | rw_lock_x_unlock(&btr_search_latch); | 1917 | rw_lock_x_unlock(btr_search_get_latch(index->id)); |
909 | 1850 | } | 1918 | } |
910 | 1851 | } | 1919 | } |
911 | 1852 | 1920 | ||
912 | 1853 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG | 1921 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG |
913 | 1854 | /********************************************************************//** | 1922 | /********************************************************************//** |
915 | 1855 | Validates the search system. | 1923 | Validates one hash table in the search system. |
916 | 1856 | @return TRUE if ok */ | 1924 | @return TRUE if ok */ |
918 | 1857 | UNIV_INTERN | 1925 | static |
919 | 1858 | ibool | 1926 | ibool |
922 | 1859 | btr_search_validate(void) | 1927 | btr_search_validate_one_table( |
923 | 1860 | /*=====================*/ | 1928 | /*==========================*/ |
924 | 1929 | ulint t) | ||
925 | 1861 | { | 1930 | { |
926 | 1862 | ha_node_t* node; | 1931 | ha_node_t* node; |
927 | 1863 | ulint n_page_dumps = 0; | 1932 | ulint n_page_dumps = 0; |
928 | @@ -1874,24 +1943,24 @@ | |||
929 | 1874 | 1943 | ||
930 | 1875 | rec_offs_init(offsets_); | 1944 | rec_offs_init(offsets_); |
931 | 1876 | 1945 | ||
932 | 1877 | rw_lock_x_lock(&btr_search_latch); | ||
933 | 1878 | buf_pool_mutex_enter_all(); | 1946 | buf_pool_mutex_enter_all(); |
934 | 1879 | 1947 | ||
936 | 1880 | cell_count = hash_get_n_cells(btr_search_sys->hash_index); | 1948 | cell_count = hash_get_n_cells(btr_search_sys->hash_index[t]); |
937 | 1881 | 1949 | ||
938 | 1882 | for (i = 0; i < cell_count; i++) { | 1950 | for (i = 0; i < cell_count; i++) { |
939 | 1883 | /* We release btr_search_latch every once in a while to | 1951 | /* We release btr_search_latch every once in a while to |
940 | 1884 | give other queries a chance to run. */ | 1952 | give other queries a chance to run. */ |
941 | 1885 | if ((i != 0) && ((i % chunk_size) == 0)) { | 1953 | if ((i != 0) && ((i % chunk_size) == 0)) { |
942 | 1886 | buf_pool_mutex_exit_all(); | 1954 | buf_pool_mutex_exit_all(); |
944 | 1887 | rw_lock_x_unlock(&btr_search_latch); | 1955 | btr_search_x_unlock_all(); |
945 | 1888 | os_thread_yield(); | 1956 | os_thread_yield(); |
947 | 1889 | rw_lock_x_lock(&btr_search_latch); | 1957 | btr_search_x_lock_all(); |
948 | 1890 | buf_pool_mutex_enter_all(); | 1958 | buf_pool_mutex_enter_all(); |
949 | 1891 | } | 1959 | } |
950 | 1892 | 1960 | ||
951 | 1893 | node = (ha_node_t*) | 1961 | node = (ha_node_t*) |
953 | 1894 | hash_get_nth_cell(btr_search_sys->hash_index, i)->node; | 1962 | hash_get_nth_cell(btr_search_sys->hash_index[t], |
954 | 1963 | i)->node; | ||
955 | 1895 | 1964 | ||
956 | 1896 | for (; node != NULL; node = node->next) { | 1965 | for (; node != NULL; node = node->next) { |
957 | 1897 | const buf_block_t* block | 1966 | const buf_block_t* block |
958 | @@ -2000,23 +2069,49 @@ | |||
959 | 2000 | give other queries a chance to run. */ | 2069 | give other queries a chance to run. */ |
960 | 2001 | if (i != 0) { | 2070 | if (i != 0) { |
961 | 2002 | buf_pool_mutex_exit_all(); | 2071 | buf_pool_mutex_exit_all(); |
963 | 2003 | rw_lock_x_unlock(&btr_search_latch); | 2072 | btr_search_x_unlock_all(); |
964 | 2004 | os_thread_yield(); | 2073 | os_thread_yield(); |
966 | 2005 | rw_lock_x_lock(&btr_search_latch); | 2074 | btr_search_x_lock_all(); |
967 | 2006 | buf_pool_mutex_enter_all(); | 2075 | buf_pool_mutex_enter_all(); |
968 | 2007 | } | 2076 | } |
969 | 2008 | 2077 | ||
971 | 2009 | if (!ha_validate(btr_search_sys->hash_index, i, end_index)) { | 2078 | if (!ha_validate(btr_search_sys->hash_index[t], i, |
972 | 2079 | end_index)) { | ||
973 | 2010 | ok = FALSE; | 2080 | ok = FALSE; |
974 | 2011 | } | 2081 | } |
975 | 2012 | } | 2082 | } |
976 | 2013 | 2083 | ||
977 | 2014 | buf_pool_mutex_exit_all(); | 2084 | buf_pool_mutex_exit_all(); |
978 | 2015 | rw_lock_x_unlock(&btr_search_latch); | ||
979 | 2016 | if (UNIV_LIKELY_NULL(heap)) { | 2085 | if (UNIV_LIKELY_NULL(heap)) { |
980 | 2017 | mem_heap_free(heap); | 2086 | mem_heap_free(heap); |
981 | 2018 | } | 2087 | } |
982 | 2019 | 2088 | ||
983 | 2020 | return(ok); | 2089 | return(ok); |
984 | 2021 | } | 2090 | } |
985 | 2091 | |||
986 | 2092 | /********************************************************************//** | ||
987 | 2093 | Validates the search system. | ||
988 | 2094 | @return TRUE if ok */ | ||
989 | 2095 | UNIV_INTERN | ||
990 | 2096 | ibool | ||
991 | 2097 | btr_search_validate(void) | ||
992 | 2098 | /*=====================*/ | ||
993 | 2099 | { | ||
994 | 2100 | ulint i; | ||
995 | 2101 | ibool ok = TRUE; | ||
996 | 2102 | |||
997 | 2103 | btr_search_x_lock_all(); | ||
998 | 2104 | |||
999 | 2105 | for (i = 0; i < btr_search_index_num; i++) { | ||
1000 | 2106 | |||
1001 | 2107 | if (!btr_search_validate_one_table(i)) | ||
1002 | 2108 | ok = FALSE; | ||
1003 | 2109 | } | ||
1004 | 2110 | |||
1005 | 2111 | btr_search_x_unlock_all(); | ||
1006 | 2112 | |||
1007 | 2113 | return(ok); | ||
1008 | 2114 | } | ||
1009 | 2115 | |||
1010 | 2116 | |||
1011 | 2022 | #endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ | 2117 | #endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ |
1012 | 2023 | 2118 | ||
1013 | === modified file 'Percona-Server/storage/innobase/buf/buf0buf.cc' | |||
1014 | --- Percona-Server/storage/innobase/buf/buf0buf.cc 2013-08-26 15:36:54 +0000 | |||
1015 | +++ Percona-Server/storage/innobase/buf/buf0buf.cc 2013-08-29 17:07:33 +0000 | |||
1016 | @@ -1013,6 +1013,7 @@ | |||
1017 | 1013 | 1013 | ||
1018 | 1014 | block->check_index_page_at_flush = FALSE; | 1014 | block->check_index_page_at_flush = FALSE; |
1019 | 1015 | block->index = NULL; | 1015 | block->index = NULL; |
1020 | 1016 | block->btr_search_latch = NULL; | ||
1021 | 1016 | 1017 | ||
1022 | 1017 | #ifdef UNIV_DEBUG | 1018 | #ifdef UNIV_DEBUG |
1023 | 1018 | block->page.in_page_hash = FALSE; | 1019 | block->page.in_page_hash = FALSE; |
1024 | @@ -1484,7 +1485,7 @@ | |||
1025 | 1484 | ulint p; | 1485 | ulint p; |
1026 | 1485 | 1486 | ||
1027 | 1486 | #ifdef UNIV_SYNC_DEBUG | 1487 | #ifdef UNIV_SYNC_DEBUG |
1029 | 1487 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 1488 | ut_ad(btr_search_own_all(RW_LOCK_EX)); |
1030 | 1488 | #endif /* UNIV_SYNC_DEBUG */ | 1489 | #endif /* UNIV_SYNC_DEBUG */ |
1031 | 1489 | ut_ad(!btr_search_enabled); | 1490 | ut_ad(!btr_search_enabled); |
1032 | 1490 | 1491 | ||
1033 | @@ -2208,6 +2209,7 @@ | |||
1034 | 2208 | { | 2209 | { |
1035 | 2209 | block->check_index_page_at_flush = FALSE; | 2210 | block->check_index_page_at_flush = FALSE; |
1036 | 2210 | block->index = NULL; | 2211 | block->index = NULL; |
1037 | 2212 | block->btr_search_latch = NULL; | ||
1038 | 2211 | 2213 | ||
1039 | 2212 | block->n_hash_helps = 0; | 2214 | block->n_hash_helps = 0; |
1040 | 2213 | block->n_fields = 1; | 2215 | block->n_fields = 1; |
1041 | 2214 | 2216 | ||
1042 | === modified file 'Percona-Server/storage/innobase/dict/dict0dict.cc' | |||
1043 | --- Percona-Server/storage/innobase/dict/dict0dict.cc 2013-08-14 03:57:21 +0000 | |||
1044 | +++ Percona-Server/storage/innobase/dict/dict0dict.cc 2013-08-29 17:07:33 +0000 | |||
1045 | @@ -1208,7 +1208,8 @@ | |||
1046 | 1208 | 1208 | ||
1047 | 1209 | See also: dict_index_remove_from_cache_low() */ | 1209 | See also: dict_index_remove_from_cache_low() */ |
1048 | 1210 | 1210 | ||
1050 | 1211 | if (btr_search_info_get_ref_count(info) > 0) { | 1211 | if (btr_search_info_get_ref_count(info, index->id) |
1051 | 1212 | > 0) { | ||
1052 | 1212 | return(FALSE); | 1213 | return(FALSE); |
1053 | 1213 | } | 1214 | } |
1054 | 1214 | } | 1215 | } |
1055 | @@ -2483,7 +2484,8 @@ | |||
1056 | 2483 | zero. See also: dict_table_can_be_evicted() */ | 2484 | zero. See also: dict_table_can_be_evicted() */ |
1057 | 2484 | 2485 | ||
1058 | 2485 | do { | 2486 | do { |
1060 | 2486 | ulint ref_count = btr_search_info_get_ref_count(info); | 2487 | ulint ref_count = btr_search_info_get_ref_count(info, |
1061 | 2488 | index->id); | ||
1062 | 2487 | 2489 | ||
1063 | 2488 | if (ref_count == 0) { | 2490 | if (ref_count == 0) { |
1064 | 2489 | break; | 2491 | break; |
1065 | 2490 | 2492 | ||
1066 | === modified file 'Percona-Server/storage/innobase/ha/ha0ha.cc' | |||
1067 | --- Percona-Server/storage/innobase/ha/ha0ha.cc 2013-08-06 15:16:34 +0000 | |||
1068 | +++ Percona-Server/storage/innobase/ha/ha0ha.cc 2013-08-29 17:07:33 +0000 | |||
1069 | @@ -98,6 +98,33 @@ | |||
1070 | 98 | return(table); | 98 | return(table); |
1071 | 99 | } | 99 | } |
1072 | 100 | 100 | ||
1073 | 101 | #ifdef UNIV_SYNC_DEBUG | ||
1074 | 102 | /*************************************************************//** | ||
1075 | 103 | Verifies that the specified hash table is a part of adaptive hash index and | ||
1076 | 104 | that its corresponding latch is X-latched by the current thread. */ | ||
1077 | 105 | static | ||
1078 | 106 | bool | ||
1079 | 107 | ha_assert_btr_x_locked( | ||
1080 | 108 | /*===================*/ | ||
1081 | 109 | const hash_table_t* table) /*!<in: hash table to check */ | ||
1082 | 110 | { | ||
1083 | 111 | ulint i; | ||
1084 | 112 | |||
1085 | 113 | ut_ad(table->adaptive); | ||
1086 | 114 | |||
1087 | 115 | for (i = 0; i < btr_search_index_num; i++) { | ||
1088 | 116 | if (btr_search_sys->hash_index[i] == table) { | ||
1089 | 117 | break; | ||
1090 | 118 | } | ||
1091 | 119 | } | ||
1092 | 120 | |||
1093 | 121 | ut_ad(i < btr_search_index_num); | ||
1094 | 122 | ut_ad(rw_lock_own(btr_search_latch_arr[i], RW_LOCK_EX)); | ||
1095 | 123 | |||
1096 | 124 | return(true); | ||
1097 | 125 | } | ||
1098 | 126 | #endif /* UNIV_SYNC_DEBUG */ | ||
1099 | 127 | |||
1100 | 101 | /*************************************************************//** | 128 | /*************************************************************//** |
1101 | 102 | Empties a hash table and frees the memory heaps. */ | 129 | Empties a hash table and frees the memory heaps. */ |
1102 | 103 | UNIV_INTERN | 130 | UNIV_INTERN |
1103 | @@ -112,8 +139,7 @@ | |||
1104 | 112 | ut_ad(table); | 139 | ut_ad(table); |
1105 | 113 | ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); | 140 | ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); |
1106 | 114 | #ifdef UNIV_SYNC_DEBUG | 141 | #ifdef UNIV_SYNC_DEBUG |
1109 | 115 | ut_ad(!table->adaptive | 142 | ut_ad(!table->adaptive || ha_assert_btr_x_locked(table)); |
1108 | 116 | || rw_lock_own(&btr_search_latch, RW_LOCK_EXCLUSIVE)); | ||
1110 | 117 | #endif /* UNIV_SYNC_DEBUG */ | 143 | #endif /* UNIV_SYNC_DEBUG */ |
1111 | 118 | 144 | ||
1112 | 119 | /* Free the memory heaps. */ | 145 | /* Free the memory heaps. */ |
1113 | @@ -274,7 +300,7 @@ | |||
1114 | 274 | ut_ad(table); | 300 | ut_ad(table); |
1115 | 275 | ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); | 301 | ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); |
1116 | 276 | #ifdef UNIV_SYNC_DEBUG | 302 | #ifdef UNIV_SYNC_DEBUG |
1118 | 277 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 303 | ut_ad(ha_assert_btr_x_locked(table)); |
1119 | 278 | #endif /* UNIV_SYNC_DEBUG */ | 304 | #endif /* UNIV_SYNC_DEBUG */ |
1120 | 279 | ut_ad(btr_search_enabled); | 305 | ut_ad(btr_search_enabled); |
1121 | 280 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG | 306 | #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG |
1122 | @@ -313,7 +339,7 @@ | |||
1123 | 313 | ut_a(new_block->frame == page_align(new_data)); | 339 | ut_a(new_block->frame == page_align(new_data)); |
1124 | 314 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ | 340 | #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ |
1125 | 315 | #ifdef UNIV_SYNC_DEBUG | 341 | #ifdef UNIV_SYNC_DEBUG |
1127 | 316 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 342 | ut_ad(ha_assert_btr_x_locked(table)); |
1128 | 317 | #endif /* UNIV_SYNC_DEBUG */ | 343 | #endif /* UNIV_SYNC_DEBUG */ |
1129 | 318 | 344 | ||
1130 | 319 | if (!btr_search_enabled) { | 345 | if (!btr_search_enabled) { |
1131 | 320 | 346 | ||
1132 | === modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc' | |||
1133 | --- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-08-22 13:38:28 +0000 | |||
1134 | +++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-08-29 17:07:33 +0000 | |||
1135 | @@ -16398,6 +16398,12 @@ | |||
1136 | 16398 | "Disable with --skip-innodb-adaptive-hash-index.", | 16398 | "Disable with --skip-innodb-adaptive-hash-index.", |
1137 | 16399 | NULL, innodb_adaptive_hash_index_update, TRUE); | 16399 | NULL, innodb_adaptive_hash_index_update, TRUE); |
1138 | 16400 | 16400 | ||
1139 | 16401 | static MYSQL_SYSVAR_ULONG(adaptive_hash_index_partitions, btr_search_index_num, | ||
1140 | 16402 | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, | ||
1141 | 16403 | "Number of InnoDB adaptive hash index partitions (default 1: disable " | ||
1142 | 16404 | "partitioning)", | ||
1143 | 16405 | NULL, NULL, 1, 1, sizeof(ulint) * 8, 0); | ||
1144 | 16406 | |||
1145 | 16401 | static MYSQL_SYSVAR_ULONG(replication_delay, srv_replication_delay, | 16407 | static MYSQL_SYSVAR_ULONG(replication_delay, srv_replication_delay, |
1146 | 16402 | PLUGIN_VAR_RQCMDARG, | 16408 | PLUGIN_VAR_RQCMDARG, |
1147 | 16403 | "Replication thread delay (ms) on the slave server if " | 16409 | "Replication thread delay (ms) on the slave server if " |
1148 | @@ -17057,6 +17063,7 @@ | |||
1149 | 17057 | MYSQL_SYSVAR(stats_persistent_sample_pages), | 17063 | MYSQL_SYSVAR(stats_persistent_sample_pages), |
1150 | 17058 | MYSQL_SYSVAR(stats_auto_recalc), | 17064 | MYSQL_SYSVAR(stats_auto_recalc), |
1151 | 17059 | MYSQL_SYSVAR(adaptive_hash_index), | 17065 | MYSQL_SYSVAR(adaptive_hash_index), |
1152 | 17066 | MYSQL_SYSVAR(adaptive_hash_index_partitions), | ||
1153 | 17060 | MYSQL_SYSVAR(stats_method), | 17067 | MYSQL_SYSVAR(stats_method), |
1154 | 17061 | MYSQL_SYSVAR(replication_delay), | 17068 | MYSQL_SYSVAR(replication_delay), |
1155 | 17062 | MYSQL_SYSVAR(status_file), | 17069 | MYSQL_SYSVAR(status_file), |
1156 | 17063 | 17070 | ||
1157 | === modified file 'Percona-Server/storage/innobase/handler/xtradb_i_s.cc' | |||
1158 | --- Percona-Server/storage/innobase/handler/xtradb_i_s.cc 2012-09-11 06:54:10 +0000 | |||
1159 | +++ Percona-Server/storage/innobase/handler/xtradb_i_s.cc 2013-08-29 17:07:33 +0000 | |||
1160 | @@ -329,34 +329,34 @@ | |||
1161 | 329 | 329 | ||
1162 | 330 | if (btr_search_sys) | 330 | if (btr_search_sys) |
1163 | 331 | { | 331 | { |
1192 | 332 | ulint btr_search_sys_subtotal= 0; | 332 | ulint btr_search_sys_subtotal; |
1193 | 333 | 333 | const hash_table_t* hash_index_0 | |
1194 | 334 | rw_lock_s_lock(&btr_search_latch); | 334 | = btr_search_sys->hash_index[0]; |
1195 | 335 | if (btr_search_sys->hash_index->heap) { | 335 | |
1196 | 336 | btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap); | 336 | if (hash_index_0->heap) { |
1197 | 337 | } else { | 337 | btr_search_sys_subtotal |
1198 | 338 | btr_search_sys_subtotal = 0; | 338 | = mem_heap_get_size(hash_index_0->heap); |
1199 | 339 | for (unsigned int i=0; | 339 | } else { |
1200 | 340 | i < btr_search_sys->hash_index->n_sync_obj; | 340 | for (ulint i = 0; i < hash_index_0->n_sync_obj; i++) { |
1201 | 341 | i++) { | 341 | btr_search_sys_subtotal |
1202 | 342 | btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]); | 342 | += mem_heap_get_size(hash_index_0 |
1203 | 343 | } | 343 | ->heaps[i]); |
1204 | 344 | } | 344 | } |
1205 | 345 | rw_lock_s_unlock(&btr_search_latch); | 345 | } |
1206 | 346 | 346 | btr_search_sys_subtotal *= btr_search_index_num; | |
1207 | 347 | OK(field_store_string(fields[INT_HASH_TABLES_NAME], | 347 | |
1208 | 348 | "Adaptive hash index")); | 348 | OK(field_store_string(fields[INT_HASH_TABLES_NAME], |
1209 | 349 | OK(field_store_ulint(fields[INT_HASH_TABLES_TOTAL], | 349 | "Adaptive hash index")); |
1210 | 350 | btr_search_sys_subtotal | 350 | OK(field_store_ulint(fields[INT_HASH_TABLES_TOTAL], |
1211 | 351 | + (btr_search_sys->hash_index->n_cells | 351 | btr_search_sys_subtotal |
1212 | 352 | * sizeof(hash_cell_t)))); | 352 | + (hash_index_0->n_cells |
1213 | 353 | OK(field_store_ulint(fields[INT_HASH_TABLES_CONSTANT], | 353 | * sizeof(hash_cell_t)))); |
1214 | 354 | (btr_search_sys->hash_index->n_cells | 354 | OK(field_store_ulint(fields[INT_HASH_TABLES_CONSTANT], |
1215 | 355 | * sizeof(hash_cell_t)))); | 355 | (hash_index_0->n_cells |
1216 | 356 | OK(field_store_ulint(fields[INT_HASH_TABLES_VARIABLE], | 356 | * sizeof(hash_cell_t)))); |
1217 | 357 | btr_search_sys_subtotal)); | 357 | OK(field_store_ulint(fields[INT_HASH_TABLES_VARIABLE], |
1218 | 358 | OK(schema_table_store_record(thd, table)); | 358 | btr_search_sys_subtotal)); |
1219 | 359 | 359 | OK(schema_table_store_record(thd, table)); | |
1220 | 360 | } | 360 | } |
1221 | 361 | 361 | ||
1222 | 362 | { | 362 | { |
1223 | 363 | 363 | ||
1224 | === modified file 'Percona-Server/storage/innobase/include/btr0sea.h' | |||
1225 | --- Percona-Server/storage/innobase/include/btr0sea.h 2013-08-06 15:16:34 +0000 | |||
1226 | +++ Percona-Server/storage/innobase/include/btr0sea.h 2013-08-29 17:07:33 +0000 | |||
1227 | @@ -86,7 +86,8 @@ | |||
1228 | 86 | ulint | 86 | ulint |
1229 | 87 | btr_search_info_get_ref_count( | 87 | btr_search_info_get_ref_count( |
1230 | 88 | /*==========================*/ | 88 | /*==========================*/ |
1232 | 89 | btr_search_t* info); /*!< in: search info. */ | 89 | btr_search_t* info, /*!< in: search info. */ |
1233 | 90 | index_id_t key); /*!< in: id of the index owning search info */ | ||
1234 | 90 | /*********************************************************************//** | 91 | /*********************************************************************//** |
1235 | 91 | Updates the search info. */ | 92 | Updates the search info. */ |
1236 | 92 | UNIV_INLINE | 93 | UNIV_INLINE |
1237 | @@ -193,6 +194,55 @@ | |||
1238 | 193 | # define btr_search_validate() TRUE | 194 | # define btr_search_validate() TRUE |
1239 | 194 | #endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ | 195 | #endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ |
1240 | 195 | 196 | ||
1241 | 197 | /********************************************************************//** | ||
1242 | 198 | Returns the adaptive hash index table for a given index key. | ||
1243 | 199 | @return the adaptive hash index table for a given index key */ | ||
1244 | 200 | UNIV_INLINE | ||
1245 | 201 | hash_table_t* | ||
1246 | 202 | btr_search_get_hash_index( | ||
1247 | 203 | /*======================*/ | ||
1248 | 204 | index_id_t key) /*!< in: index key */ | ||
1249 | 205 | __attribute__((pure,warn_unused_result)); | ||
1250 | 206 | |||
1251 | 207 | /********************************************************************//** | ||
1252 | 208 | Returns the adaptive hash index latch for a given index key. | ||
1253 | 209 | @return the adaptive hash index latch for a given index key */ | ||
1254 | 210 | UNIV_INLINE | ||
1255 | 211 | rw_lock_t* | ||
1256 | 212 | btr_search_get_latch( | ||
1257 | 213 | /*=================*/ | ||
1258 | 214 | index_id_t key) /*!< in: index key */ | ||
1259 | 215 | __attribute__((pure,warn_unused_result)); | ||
1260 | 216 | |||
1261 | 217 | /********************************************************************//** | ||
1262 | 218 | Latches all adaptive hash index latches in exclusive mode. */ | ||
1263 | 219 | UNIV_INLINE | ||
1264 | 220 | void | ||
1265 | 221 | btr_search_x_lock_all(void); | ||
1266 | 222 | /*========================*/ | ||
1267 | 223 | |||
1268 | 224 | /********************************************************************//** | ||
1269 | 225 | Unlatches all adaptive hash index latches in exclusive mode. */ | ||
1270 | 226 | UNIV_INLINE | ||
1271 | 227 | void | ||
1272 | 228 | btr_search_x_unlock_all(void); | ||
1273 | 229 | /*==========================*/ | ||
1274 | 230 | |||
1275 | 231 | #ifdef UNIV_SYNC_DEBUG | ||
1276 | 232 | /******************************************************************//** | ||
1277 | 233 | Checks if the thread has locked all the adaptive hash index latches in the | ||
1278 | 234 | specified mode. | ||
1279 | 235 | |||
1280 | 236 | @return true if all latches are locked by the current thread, false | ||
1281 | 237 | otherwise. */ | ||
1282 | 238 | UNIV_INLINE | ||
1283 | 239 | bool | ||
1284 | 240 | btr_search_own_all( | ||
1285 | 241 | /*===============*/ | ||
1286 | 242 | ulint lock_type) | ||
1287 | 243 | __attribute__((warn_unused_result)); | ||
1288 | 244 | #endif /* UNIV_SYNC_DEBUG */ | ||
1289 | 245 | |||
1290 | 196 | /** The search info struct in an index */ | 246 | /** The search info struct in an index */ |
1291 | 197 | struct btr_search_t{ | 247 | struct btr_search_t{ |
1292 | 198 | ulint ref_count; /*!< Number of blocks in this index tree | 248 | ulint ref_count; /*!< Number of blocks in this index tree |
1293 | @@ -250,7 +300,7 @@ | |||
1294 | 250 | 300 | ||
1295 | 251 | /** The hash index system */ | 301 | /** The hash index system */ |
1296 | 252 | struct btr_search_sys_t{ | 302 | struct btr_search_sys_t{ |
1298 | 253 | hash_table_t* hash_index; /*!< the adaptive hash index, | 303 | hash_table_t** hash_index; /*!< the adaptive hash index, |
1299 | 254 | mapping dtuple_fold values | 304 | mapping dtuple_fold values |
1300 | 255 | to rec_t pointers on index pages */ | 305 | to rec_t pointers on index pages */ |
1301 | 256 | }; | 306 | }; |
1302 | 257 | 307 | ||
1303 | === modified file 'Percona-Server/storage/innobase/include/btr0sea.ic' | |||
1304 | --- Percona-Server/storage/innobase/include/btr0sea.ic 2013-08-06 15:16:34 +0000 | |||
1305 | +++ Percona-Server/storage/innobase/include/btr0sea.ic 2013-08-29 17:07:33 +0000 | |||
1306 | @@ -60,8 +60,8 @@ | |||
1307 | 60 | btr_search_t* info; | 60 | btr_search_t* info; |
1308 | 61 | 61 | ||
1309 | 62 | #ifdef UNIV_SYNC_DEBUG | 62 | #ifdef UNIV_SYNC_DEBUG |
1312 | 63 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 63 | ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_SHARED)); |
1313 | 64 | ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); | 64 | ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_EX)); |
1314 | 65 | #endif /* UNIV_SYNC_DEBUG */ | 65 | #endif /* UNIV_SYNC_DEBUG */ |
1315 | 66 | 66 | ||
1316 | 67 | info = btr_search_get_info(index); | 67 | info = btr_search_get_info(index); |
1317 | @@ -80,3 +80,80 @@ | |||
1318 | 80 | 80 | ||
1319 | 81 | btr_search_info_update_slow(info, cursor); | 81 | btr_search_info_update_slow(info, cursor); |
1320 | 82 | } | 82 | } |
1321 | 83 | |||
1322 | 84 | /********************************************************************//** | ||
1323 | 85 | Returns the adaptive hash index table for a given index key. | ||
1324 | 86 | @return the adaptive hash index table for a given index key */ | ||
1325 | 87 | UNIV_INLINE | ||
1326 | 88 | hash_table_t* | ||
1327 | 89 | btr_search_get_hash_index( | ||
1328 | 90 | /*======================*/ | ||
1329 | 91 | index_id_t key) /*!< in: index key */ | ||
1330 | 92 | { | ||
1331 | 93 | return(btr_search_sys->hash_index[key % btr_search_index_num]); | ||
1332 | 94 | } | ||
1333 | 95 | |||
1334 | 96 | /********************************************************************//** | ||
1335 | 97 | Returns the adaptive hash index latch for a given index key. | ||
1336 | 98 | @return the adaptive hash index latch for a given index key */ | ||
1337 | 99 | UNIV_INLINE | ||
1338 | 100 | rw_lock_t* | ||
1339 | 101 | btr_search_get_latch( | ||
1340 | 102 | /*=================*/ | ||
1341 | 103 | index_id_t key) /*!< in: index key */ | ||
1342 | 104 | { | ||
1343 | 105 | return(btr_search_latch_arr[key % btr_search_index_num]); | ||
1344 | 106 | } | ||
1345 | 107 | |||
1346 | 108 | /********************************************************************//** | ||
1347 | 109 | Latches all adaptive hash index latches in exclusive mode. */ | ||
1348 | 110 | UNIV_INLINE | ||
1349 | 111 | void | ||
1350 | 112 | btr_search_x_lock_all(void) | ||
1351 | 113 | /*=======================*/ | ||
1352 | 114 | { | ||
1353 | 115 | ulint i; | ||
1354 | 116 | |||
1355 | 117 | for (i = 0; i < btr_search_index_num; i++) { | ||
1356 | 118 | rw_lock_x_lock(btr_search_latch_arr[i]); | ||
1357 | 119 | } | ||
1358 | 120 | } | ||
1359 | 121 | |||
1360 | 122 | /********************************************************************//** | ||
1361 | 123 | Unlatches all adaptive hash index latches in exclusive mode. */ | ||
1362 | 124 | UNIV_INLINE | ||
1363 | 125 | void | ||
1364 | 126 | btr_search_x_unlock_all(void) | ||
1365 | 127 | /*==========================*/ | ||
1366 | 128 | { | ||
1367 | 129 | ulint i; | ||
1368 | 130 | |||
1369 | 131 | for (i = 0; i < btr_search_index_num; i++) { | ||
1370 | 132 | rw_lock_x_unlock(btr_search_latch_arr[i]); | ||
1371 | 133 | } | ||
1372 | 134 | } | ||
1373 | 135 | |||
1374 | 136 | #ifdef UNIV_SYNC_DEBUG | ||
1375 | 137 | /******************************************************************//** | ||
1376 | 138 | Checks if the thread has locked all the adaptive hash index latches in the | ||
1377 | 139 | specified mode. | ||
1378 | 140 | |||
1379 | 141 | @return true if all latches are locked by the current thread, false | ||
1380 | 142 | otherwise. */ | ||
1381 | 143 | UNIV_INLINE | ||
1382 | 144 | bool | ||
1383 | 145 | btr_search_own_all( | ||
1384 | 146 | /*===============*/ | ||
1385 | 147 | ulint lock_type) | ||
1386 | 148 | { | ||
1387 | 149 | ulint i; | ||
1388 | 150 | |||
1389 | 151 | for (i = 0; i < btr_search_index_num; i++) { | ||
1390 | 152 | if (!rw_lock_own(btr_search_latch_arr[i], lock_type)) { | ||
1391 | 153 | return(false); | ||
1392 | 154 | } | ||
1393 | 155 | } | ||
1394 | 156 | |||
1395 | 157 | return(true); | ||
1396 | 158 | } | ||
1397 | 159 | #endif /* UNIV_SYNC_DEBUG */ | ||
1398 | 83 | 160 | ||
1399 | === modified file 'Percona-Server/storage/innobase/include/btr0types.h' | |||
1400 | --- Percona-Server/storage/innobase/include/btr0types.h 2013-08-06 15:16:34 +0000 | |||
1401 | +++ Percona-Server/storage/innobase/include/btr0types.h 2013-08-29 17:07:33 +0000 | |||
1402 | @@ -54,17 +54,17 @@ | |||
1403 | 54 | 54 | ||
1404 | 55 | Bear in mind (3) and (4) when using the hash index. | 55 | Bear in mind (3) and (4) when using the hash index. |
1405 | 56 | */ | 56 | */ |
1407 | 57 | extern rw_lock_t* btr_search_latch_temp; | 57 | extern rw_lock_t** btr_search_latch_arr; |
1408 | 58 | 58 | ||
1409 | 59 | #endif /* UNIV_HOTBACKUP */ | 59 | #endif /* UNIV_HOTBACKUP */ |
1410 | 60 | 60 | ||
1411 | 61 | /** The latch protecting the adaptive search system */ | ||
1412 | 62 | #define btr_search_latch (*btr_search_latch_temp) | ||
1413 | 63 | |||
1414 | 64 | /** Flag: has the search system been enabled? | 61 | /** Flag: has the search system been enabled? |
1415 | 65 | Protected by btr_search_latch. */ | 62 | Protected by btr_search_latch. */ |
1416 | 66 | extern char btr_search_enabled; | 63 | extern char btr_search_enabled; |
1417 | 67 | 64 | ||
1418 | 65 | /** Number of adaptive hash index partitions */ | ||
1419 | 66 | extern ulint btr_search_index_num; | ||
1420 | 67 | |||
1421 | 68 | #ifdef UNIV_BLOB_DEBUG | 68 | #ifdef UNIV_BLOB_DEBUG |
1422 | 69 | # include "buf0types.h" | 69 | # include "buf0types.h" |
1423 | 70 | /** An index->blobs entry for keeping track of off-page column references */ | 70 | /** An index->blobs entry for keeping track of off-page column references */ |
1424 | 71 | 71 | ||
1425 | === modified file 'Percona-Server/storage/innobase/include/buf0buf.h' | |||
1426 | --- Percona-Server/storage/innobase/include/buf0buf.h 2013-08-26 15:36:54 +0000 | |||
1427 | +++ Percona-Server/storage/innobase/include/buf0buf.h 2013-08-29 17:07:33 +0000 | |||
1428 | @@ -1700,6 +1700,8 @@ | |||
1429 | 1700 | complete, though: there may | 1700 | complete, though: there may |
1430 | 1701 | have been hash collisions, | 1701 | have been hash collisions, |
1431 | 1702 | record deletions, etc. */ | 1702 | record deletions, etc. */ |
1432 | 1703 | rw_lock_t* btr_search_latch;/*!< Adaptive hash index latch for the | ||
1433 | 1704 | index this block belongs to or NULL */ | ||
1434 | 1703 | /* @} */ | 1705 | /* @} */ |
1435 | 1704 | # ifdef UNIV_SYNC_DEBUG | 1706 | # ifdef UNIV_SYNC_DEBUG |
1436 | 1705 | /** @name Debug fields */ | 1707 | /** @name Debug fields */ |
1437 | 1706 | 1708 | ||
1438 | === modified file 'Percona-Server/storage/innobase/include/mtr0log.ic' | |||
1439 | --- Percona-Server/storage/innobase/include/mtr0log.ic 2013-08-06 15:16:34 +0000 | |||
1440 | +++ Percona-Server/storage/innobase/include/mtr0log.ic 2013-08-29 17:07:33 +0000 | |||
1441 | @@ -28,6 +28,7 @@ | |||
1442 | 28 | #include "buf0buf.h" | 28 | #include "buf0buf.h" |
1443 | 29 | #include "buf0dblwr.h" | 29 | #include "buf0dblwr.h" |
1444 | 30 | #include "fsp0types.h" | 30 | #include "fsp0types.h" |
1445 | 31 | #include "btr0types.h" | ||
1446 | 31 | #include "trx0sys.h" | 32 | #include "trx0sys.h" |
1447 | 32 | 33 | ||
1448 | 33 | /********************************************************//** | 34 | /********************************************************//** |
1449 | 34 | 35 | ||
1450 | === modified file 'Percona-Server/storage/innobase/include/que0que.h' | |||
1451 | --- Percona-Server/storage/innobase/include/que0que.h 2013-08-06 15:16:34 +0000 | |||
1452 | +++ Percona-Server/storage/innobase/include/que0que.h 2013-08-29 17:07:33 +0000 | |||
1453 | @@ -29,6 +29,7 @@ | |||
1454 | 29 | #include "univ.i" | 29 | #include "univ.i" |
1455 | 30 | #include "data0data.h" | 30 | #include "data0data.h" |
1456 | 31 | #include "dict0types.h" | 31 | #include "dict0types.h" |
1457 | 32 | #include "btr0sea.h" | ||
1458 | 32 | #include "trx0trx.h" | 33 | #include "trx0trx.h" |
1459 | 33 | #include "trx0roll.h" | 34 | #include "trx0roll.h" |
1460 | 34 | #include "srv0srv.h" | 35 | #include "srv0srv.h" |
1461 | 35 | 36 | ||
1462 | === modified file 'Percona-Server/storage/innobase/include/read0read.h' | |||
1463 | --- Percona-Server/storage/innobase/include/read0read.h 2013-08-06 15:16:34 +0000 | |||
1464 | +++ Percona-Server/storage/innobase/include/read0read.h 2013-08-29 17:07:33 +0000 | |||
1465 | @@ -31,6 +31,7 @@ | |||
1466 | 31 | 31 | ||
1467 | 32 | #include "ut0byte.h" | 32 | #include "ut0byte.h" |
1468 | 33 | #include "ut0lst.h" | 33 | #include "ut0lst.h" |
1469 | 34 | #include "btr0types.h" | ||
1470 | 34 | #include "trx0trx.h" | 35 | #include "trx0trx.h" |
1471 | 35 | #include "trx0sys.h" | 36 | #include "trx0sys.h" |
1472 | 36 | #include "read0types.h" | 37 | #include "read0types.h" |
1473 | 37 | 38 | ||
1474 | === modified file 'Percona-Server/storage/innobase/include/trx0roll.h' | |||
1475 | --- Percona-Server/storage/innobase/include/trx0roll.h 2013-08-06 15:16:34 +0000 | |||
1476 | +++ Percona-Server/storage/innobase/include/trx0roll.h 2013-08-29 17:07:33 +0000 | |||
1477 | @@ -27,6 +27,7 @@ | |||
1478 | 27 | #define trx0roll_h | 27 | #define trx0roll_h |
1479 | 28 | 28 | ||
1480 | 29 | #include "univ.i" | 29 | #include "univ.i" |
1481 | 30 | #include "btr0types.h" | ||
1482 | 30 | #include "trx0trx.h" | 31 | #include "trx0trx.h" |
1483 | 31 | #include "trx0types.h" | 32 | #include "trx0types.h" |
1484 | 32 | #include "mtr0mtr.h" | 33 | #include "mtr0mtr.h" |
1485 | 33 | 34 | ||
1486 | === modified file 'Percona-Server/storage/innobase/include/trx0trx.h' | |||
1487 | --- Percona-Server/storage/innobase/include/trx0trx.h 2013-08-06 15:16:34 +0000 | |||
1488 | +++ Percona-Server/storage/innobase/include/trx0trx.h 2013-08-29 17:07:33 +0000 | |||
1489 | @@ -1136,10 +1136,7 @@ | |||
1490 | 1136 | 1136 | ||
1491 | 1137 | Bear in mind (3) and (4) when using the hash index. | 1137 | Bear in mind (3) and (4) when using the hash index. |
1492 | 1138 | */ | 1138 | */ |
1497 | 1139 | extern rw_lock_t* btr_search_latch_temp; | 1139 | extern rw_lock_t** btr_search_latch_arr; |
1494 | 1140 | |||
1495 | 1141 | /** The latch protecting the adaptive search system */ | ||
1496 | 1142 | #define btr_search_latch (*btr_search_latch_temp) | ||
1498 | 1143 | 1140 | ||
1499 | 1144 | #ifndef UNIV_NONINL | 1141 | #ifndef UNIV_NONINL |
1500 | 1145 | #include "trx0trx.ic" | 1142 | #include "trx0trx.ic" |
1501 | 1146 | 1143 | ||
1502 | === modified file 'Percona-Server/storage/innobase/include/trx0trx.ic' | |||
1503 | --- Percona-Server/storage/innobase/include/trx0trx.ic 2013-08-06 15:16:34 +0000 | |||
1504 | +++ Percona-Server/storage/innobase/include/trx0trx.ic 2013-08-29 17:07:33 +0000 | |||
1505 | @@ -164,17 +164,21 @@ | |||
1506 | 164 | } | 164 | } |
1507 | 165 | 165 | ||
1508 | 166 | /********************************************************************//** | 166 | /********************************************************************//** |
1510 | 167 | Releases the search latch if trx has reserved it. */ | 167 | Releases the search latches if trx has reserved them. */ |
1511 | 168 | UNIV_INLINE | 168 | UNIV_INLINE |
1512 | 169 | void | 169 | void |
1513 | 170 | trx_search_latch_release_if_reserved( | 170 | trx_search_latch_release_if_reserved( |
1514 | 171 | /*=================================*/ | 171 | /*=================================*/ |
1515 | 172 | trx_t* trx) /*!< in: transaction */ | 172 | trx_t* trx) /*!< in: transaction */ |
1516 | 173 | { | 173 | { |
1519 | 174 | if (trx->has_search_latch) { | 174 | ulint i; |
1518 | 175 | rw_lock_s_unlock(&btr_search_latch); | ||
1520 | 176 | 175 | ||
1522 | 177 | trx->has_search_latch = FALSE; | 176 | for (i = 0; i < btr_search_index_num; i++) { |
1523 | 177 | if (trx->has_search_latch & (1UL << i)) { | ||
1524 | 178 | rw_lock_s_unlock(btr_search_latch_arr[i]); | ||
1525 | 179 | } | ||
1526 | 178 | } | 180 | } |
1527 | 181 | |||
1528 | 182 | trx->has_search_latch = 0; | ||
1529 | 179 | } | 183 | } |
1530 | 180 | 184 | ||
1531 | 181 | 185 | ||
1532 | === modified file 'Percona-Server/storage/innobase/include/univ.i' | |||
1533 | --- Percona-Server/storage/innobase/include/univ.i 2013-08-06 15:16:34 +0000 | |||
1534 | +++ Percona-Server/storage/innobase/include/univ.i 2013-08-29 17:07:33 +0000 | |||
1535 | @@ -179,7 +179,6 @@ | |||
1536 | 179 | #define UNIV_COMPILE_TEST_FUNCS | 179 | #define UNIV_COMPILE_TEST_FUNCS |
1537 | 180 | */ | 180 | */ |
1538 | 181 | 181 | ||
1539 | 182 | #undef UNIV_SYNC_DEBUG | ||
1540 | 183 | #if defined HAVE_VALGRIND | 182 | #if defined HAVE_VALGRIND |
1541 | 184 | # define UNIV_DEBUG_VALGRIND | 183 | # define UNIV_DEBUG_VALGRIND |
1542 | 185 | #endif /* HAVE_VALGRIND */ | 184 | #endif /* HAVE_VALGRIND */ |
1543 | 186 | 185 | ||
1544 | === modified file 'Percona-Server/storage/innobase/os/os0file.cc' | |||
1545 | --- Percona-Server/storage/innobase/os/os0file.cc 2013-08-21 07:19:25 +0000 | |||
1546 | +++ Percona-Server/storage/innobase/os/os0file.cc 2013-08-29 17:07:33 +0000 | |||
1547 | @@ -43,6 +43,7 @@ | |||
1548 | 43 | #include "srv0start.h" | 43 | #include "srv0start.h" |
1549 | 44 | #include "fil0fil.h" | 44 | #include "fil0fil.h" |
1550 | 45 | #include "buf0buf.h" | 45 | #include "buf0buf.h" |
1551 | 46 | #include "btr0types.h" | ||
1552 | 46 | #include "trx0trx.h" | 47 | #include "trx0trx.h" |
1553 | 47 | #include "srv0mon.h" | 48 | #include "srv0mon.h" |
1554 | 48 | #ifndef UNIV_HOTBACKUP | 49 | #ifndef UNIV_HOTBACKUP |
1555 | 49 | 50 | ||
1556 | === modified file 'Percona-Server/storage/innobase/row/row0sel.cc' | |||
1557 | --- Percona-Server/storage/innobase/row/row0sel.cc 2013-08-14 03:57:21 +0000 | |||
1558 | +++ Percona-Server/storage/innobase/row/row0sel.cc 2013-08-29 17:07:33 +0000 | |||
1559 | @@ -1233,7 +1233,8 @@ | |||
1560 | 1233 | ut_ad(!plan->must_get_clust); | 1233 | ut_ad(!plan->must_get_clust); |
1561 | 1234 | #ifdef UNIV_SYNC_DEBUG | 1234 | #ifdef UNIV_SYNC_DEBUG |
1562 | 1235 | if (search_latch_locked) { | 1235 | if (search_latch_locked) { |
1564 | 1236 | ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); | 1236 | ut_ad(rw_lock_own(btr_search_get_latch(index->id), |
1565 | 1237 | RW_LOCK_SHARED)); | ||
1566 | 1237 | } | 1238 | } |
1567 | 1238 | #endif /* UNIV_SYNC_DEBUG */ | 1239 | #endif /* UNIV_SYNC_DEBUG */ |
1568 | 1239 | 1240 | ||
1569 | @@ -1405,10 +1406,11 @@ | |||
1570 | 1405 | && !plan->must_get_clust | 1406 | && !plan->must_get_clust |
1571 | 1406 | && !plan->table->big_rows) { | 1407 | && !plan->table->big_rows) { |
1572 | 1407 | if (!search_latch_locked) { | 1408 | if (!search_latch_locked) { |
1574 | 1408 | rw_lock_s_lock(&btr_search_latch); | 1409 | rw_lock_s_lock(btr_search_get_latch(index->id)); |
1575 | 1409 | 1410 | ||
1576 | 1410 | search_latch_locked = TRUE; | 1411 | search_latch_locked = TRUE; |
1578 | 1411 | } else if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_WAIT_EX) { | 1412 | } else if (rw_lock_get_writer(btr_search_get_latch(index->id)) |
1579 | 1413 | == RW_LOCK_WAIT_EX) { | ||
1580 | 1412 | 1414 | ||
1581 | 1413 | /* There is an x-latch request waiting: release the | 1415 | /* There is an x-latch request waiting: release the |
1582 | 1414 | s-latch for a moment; as an s-latch here is often | 1416 | s-latch for a moment; as an s-latch here is often |
1583 | @@ -1417,8 +1419,8 @@ | |||
1584 | 1417 | from acquiring an s-latch for a long time, lowering | 1419 | from acquiring an s-latch for a long time, lowering |
1585 | 1418 | performance significantly in multiprocessors. */ | 1420 | performance significantly in multiprocessors. */ |
1586 | 1419 | 1421 | ||
1589 | 1420 | rw_lock_s_unlock(&btr_search_latch); | 1422 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
1590 | 1421 | rw_lock_s_lock(&btr_search_latch); | 1423 | rw_lock_s_lock(btr_search_get_latch(index->id)); |
1591 | 1422 | } | 1424 | } |
1592 | 1423 | 1425 | ||
1593 | 1424 | found_flag = row_sel_try_search_shortcut(node, plan, | 1426 | found_flag = row_sel_try_search_shortcut(node, plan, |
1594 | @@ -1443,7 +1445,7 @@ | |||
1595 | 1443 | } | 1445 | } |
1596 | 1444 | 1446 | ||
1597 | 1445 | if (search_latch_locked) { | 1447 | if (search_latch_locked) { |
1599 | 1446 | rw_lock_s_unlock(&btr_search_latch); | 1448 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
1600 | 1447 | 1449 | ||
1601 | 1448 | search_latch_locked = FALSE; | 1450 | search_latch_locked = FALSE; |
1602 | 1449 | } | 1451 | } |
1603 | @@ -2019,7 +2021,7 @@ | |||
1604 | 2019 | 2021 | ||
1605 | 2020 | func_exit: | 2022 | func_exit: |
1606 | 2021 | if (search_latch_locked) { | 2023 | if (search_latch_locked) { |
1608 | 2022 | rw_lock_s_unlock(&btr_search_latch); | 2024 | rw_lock_s_unlock(btr_search_get_latch(index->id)); |
1609 | 2023 | } | 2025 | } |
1610 | 2024 | if (UNIV_LIKELY_NULL(heap)) { | 2026 | if (UNIV_LIKELY_NULL(heap)) { |
1611 | 2025 | mem_heap_free(heap); | 2027 | mem_heap_free(heap); |
1612 | @@ -3597,6 +3599,47 @@ | |||
1613 | 3597 | } | 3599 | } |
1614 | 3598 | 3600 | ||
1615 | 3599 | /********************************************************************//** | 3601 | /********************************************************************//** |
1616 | 3602 | Acquires an S latch for the adaptive hash index for a given index tree if is | ||
1617 | 3603 | not acquired already. If the current transaction already owns a latch with | ||
1618 | 3604 | a higher index in the latch array, release all the already-held S latches | ||
1619 | 3605 | and reacquire them together with the desired latch to honor the latching | ||
1620 | 3606 | order. */ | ||
1621 | 3607 | static | ||
1622 | 3608 | void | ||
1623 | 3609 | trx_search_latch_lock( | ||
1624 | 3610 | /*==================*/ | ||
1625 | 3611 | trx_t* trx, /*!< in: latching transcation */ | ||
1626 | 3612 | ulint index_id) /*!< in: index to latch AHI for */ | ||
1627 | 3613 | { | ||
1628 | 3614 | ulint latch_mask = 1UL << (index_id % btr_search_index_num); | ||
1629 | 3615 | |||
1630 | 3616 | if (!(trx->has_search_latch & latch_mask)) { | ||
1631 | 3617 | |||
1632 | 3618 | if (trx->has_search_latch < latch_mask) { | ||
1633 | 3619 | |||
1634 | 3620 | rw_lock_s_lock(btr_search_get_latch(index_id)); | ||
1635 | 3621 | trx->has_search_latch |= latch_mask; | ||
1636 | 3622 | } else { | ||
1637 | 3623 | |||
1638 | 3624 | ulint taken_latches = trx->has_search_latch; | ||
1639 | 3625 | |||
1640 | 3626 | trx_search_latch_release_if_reserved(trx); | ||
1641 | 3627 | |||
1642 | 3628 | trx->has_search_latch = taken_latches | latch_mask; | ||
1643 | 3629 | |||
1644 | 3630 | for (ulint i = 0; i < btr_search_index_num; i++) { | ||
1645 | 3631 | if (trx->has_search_latch & (1UL << i)) { | ||
1646 | 3632 | |||
1647 | 3633 | rw_lock_s_lock( | ||
1648 | 3634 | btr_search_latch_arr[i]); | ||
1649 | 3635 | } | ||
1650 | 3636 | } | ||
1651 | 3637 | } | ||
1652 | 3638 | } | ||
1653 | 3639 | } | ||
1654 | 3640 | |||
1655 | 3641 | |||
1656 | 3642 | /********************************************************************//** | ||
1657 | 3600 | Searches for rows in the database. This is used in the interface to | 3643 | Searches for rows in the database. This is used in the interface to |
1658 | 3601 | MySQL. This function opens a cursor, and also implements fetch next | 3644 | MySQL. This function opens a cursor, and also implements fetch next |
1659 | 3602 | and fetch prev. NOTE that if we do a search with a full key value | 3645 | and fetch prev. NOTE that if we do a search with a full key value |
1660 | @@ -3658,6 +3701,7 @@ | |||
1661 | 3658 | ulint* offsets = offsets_; | 3701 | ulint* offsets = offsets_; |
1662 | 3659 | ibool table_lock_waited = FALSE; | 3702 | ibool table_lock_waited = FALSE; |
1663 | 3660 | byte* next_buf = 0; | 3703 | byte* next_buf = 0; |
1664 | 3704 | bool should_release; | ||
1665 | 3661 | 3705 | ||
1666 | 3662 | rec_offs_init(offsets_); | 3706 | rec_offs_init(offsets_); |
1667 | 3663 | 3707 | ||
1668 | @@ -3733,19 +3777,28 @@ | |||
1669 | 3733 | (ulong) trx->mysql_n_tables_locked); | 3777 | (ulong) trx->mysql_n_tables_locked); |
1670 | 3734 | #endif | 3778 | #endif |
1671 | 3735 | /*-------------------------------------------------------------*/ | 3779 | /*-------------------------------------------------------------*/ |
1677 | 3736 | /* PHASE 0: Release a possible s-latch we are holding on the | 3780 | /* PHASE 0: Release possible latches we are holding on the |
1678 | 3737 | adaptive hash index latch if there is someone waiting behind */ | 3781 | adaptive hash index latches if there is someone waiting behind */ |
1679 | 3738 | 3782 | ||
1680 | 3739 | if (UNIV_UNLIKELY(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_NOT_LOCKED) | 3783 | should_release = false; |
1681 | 3740 | && trx->has_search_latch) { | 3784 | for (ulint i = 0; i < btr_search_index_num; i++) { |
1682 | 3785 | /* we should check all latches (fix Bug#791030) */ | ||
1683 | 3786 | if (UNIV_UNLIKELY(rw_lock_get_writer(btr_search_latch_arr[i]) | ||
1684 | 3787 | != RW_LOCK_NOT_LOCKED)) { | ||
1685 | 3788 | should_release = true; | ||
1686 | 3789 | break; | ||
1687 | 3790 | } | ||
1688 | 3791 | } | ||
1689 | 3792 | |||
1690 | 3793 | if (UNIV_UNLIKELY(should_release)) { | ||
1691 | 3741 | 3794 | ||
1692 | 3742 | /* There is an x-latch request on the adaptive hash index: | 3795 | /* There is an x-latch request on the adaptive hash index: |
1693 | 3743 | release the s-latch to reduce starvation and wait for | 3796 | release the s-latch to reduce starvation and wait for |
1694 | 3744 | BTR_SEA_TIMEOUT rounds before trying to keep it again over | 3797 | BTR_SEA_TIMEOUT rounds before trying to keep it again over |
1695 | 3745 | calls from MySQL */ | 3798 | calls from MySQL */ |
1696 | 3746 | 3799 | ||
1699 | 3747 | rw_lock_s_unlock(&btr_search_latch); | 3800 | /* We should release all s-latches (fix Bug#791030) */ |
1700 | 3748 | trx->has_search_latch = FALSE; | 3801 | trx_search_latch_release_if_reserved(trx); |
1701 | 3749 | 3802 | ||
1702 | 3750 | trx->search_latch_timeout = BTR_SEA_TIMEOUT; | 3803 | trx->search_latch_timeout = BTR_SEA_TIMEOUT; |
1703 | 3751 | } | 3804 | } |
1704 | @@ -3896,10 +3949,7 @@ | |||
1705 | 3896 | hash index semaphore! */ | 3949 | hash index semaphore! */ |
1706 | 3897 | 3950 | ||
1707 | 3898 | #ifndef UNIV_SEARCH_DEBUG | 3951 | #ifndef UNIV_SEARCH_DEBUG |
1712 | 3899 | if (!trx->has_search_latch) { | 3952 | trx_search_latch_lock(trx, index->id); |
1709 | 3900 | rw_lock_s_lock(&btr_search_latch); | ||
1710 | 3901 | trx->has_search_latch = TRUE; | ||
1711 | 3902 | } | ||
1713 | 3903 | #endif | 3953 | #endif |
1714 | 3904 | switch (row_sel_try_search_shortcut_for_mysql( | 3954 | switch (row_sel_try_search_shortcut_for_mysql( |
1715 | 3905 | &rec, prebuilt, &offsets, &heap, | 3955 | &rec, prebuilt, &offsets, &heap, |
1716 | @@ -3969,8 +4019,8 @@ | |||
1717 | 3969 | 4019 | ||
1718 | 3970 | trx->search_latch_timeout--; | 4020 | trx->search_latch_timeout--; |
1719 | 3971 | 4021 | ||
1722 | 3972 | rw_lock_s_unlock(&btr_search_latch); | 4022 | trx_search_latch_release_if_reserved( |
1723 | 3973 | trx->has_search_latch = FALSE; | 4023 | trx); |
1724 | 3974 | } | 4024 | } |
1725 | 3975 | 4025 | ||
1726 | 3976 | /* NOTE that we do NOT store the cursor | 4026 | /* NOTE that we do NOT store the cursor |
1727 | @@ -3992,10 +4042,7 @@ | |||
1728 | 3992 | /*-------------------------------------------------------------*/ | 4042 | /*-------------------------------------------------------------*/ |
1729 | 3993 | /* PHASE 3: Open or restore index cursor position */ | 4043 | /* PHASE 3: Open or restore index cursor position */ |
1730 | 3994 | 4044 | ||
1735 | 3995 | if (trx->has_search_latch) { | 4045 | trx_search_latch_release_if_reserved(trx); |
1732 | 3996 | rw_lock_s_unlock(&btr_search_latch); | ||
1733 | 3997 | trx->has_search_latch = FALSE; | ||
1734 | 3998 | } | ||
1736 | 3999 | 4046 | ||
1737 | 4000 | /* The state of a running trx can only be changed by the | 4047 | /* The state of a running trx can only be changed by the |
1738 | 4001 | thread that is currently serving the transaction. Because we | 4048 | thread that is currently serving the transaction. Because we |
1739 | 4002 | 4049 | ||
1740 | === modified file 'Percona-Server/storage/innobase/srv/srv0conc.cc' | |||
1741 | --- Percona-Server/storage/innobase/srv/srv0conc.cc 2013-05-10 08:51:53 +0000 | |||
1742 | +++ Percona-Server/storage/innobase/srv/srv0conc.cc 2013-08-29 17:07:33 +0000 | |||
1743 | @@ -39,6 +39,7 @@ | |||
1744 | 39 | 39 | ||
1745 | 40 | #include "srv0srv.h" | 40 | #include "srv0srv.h" |
1746 | 41 | #include "sync0sync.h" | 41 | #include "sync0sync.h" |
1747 | 42 | #include "btr0types.h" | ||
1748 | 42 | #include "trx0trx.h" | 43 | #include "trx0trx.h" |
1749 | 43 | 44 | ||
1750 | 44 | #include "mysql/plugin.h" | 45 | #include "mysql/plugin.h" |
1751 | 45 | 46 | ||
1752 | === modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc' | |||
1753 | --- Percona-Server/storage/innobase/srv/srv0srv.cc 2013-08-14 03:57:21 +0000 | |||
1754 | +++ Percona-Server/storage/innobase/srv/srv0srv.cc 2013-08-29 17:07:33 +0000 | |||
1755 | @@ -1308,17 +1308,20 @@ | |||
1756 | 1308 | os_atomic_increment_lint(&srv_read_views_memory, 0)); | 1308 | os_atomic_increment_lint(&srv_read_views_memory, 0)); |
1757 | 1309 | 1309 | ||
1758 | 1310 | /* Calculate reserved memories */ | 1310 | /* Calculate reserved memories */ |
1760 | 1311 | if (btr_search_sys && btr_search_sys->hash_index->heap) { | 1311 | if (btr_search_sys && btr_search_sys->hash_index[0]->heap) { |
1761 | 1312 | btr_search_sys_subtotal | 1312 | btr_search_sys_subtotal |
1763 | 1313 | = mem_heap_get_size(btr_search_sys->hash_index->heap); | 1313 | = mem_heap_get_size(btr_search_sys->hash_index[0] |
1764 | 1314 | ->heap); | ||
1765 | 1314 | } else { | 1315 | } else { |
1766 | 1315 | btr_search_sys_subtotal = 0; | 1316 | btr_search_sys_subtotal = 0; |
1768 | 1316 | for (i=0; i < btr_search_sys->hash_index->n_sync_obj; i++) { | 1317 | for (i=0; i < btr_search_sys->hash_index[0]->n_sync_obj; i++) { |
1769 | 1317 | btr_search_sys_subtotal | 1318 | btr_search_sys_subtotal |
1770 | 1318 | += mem_heap_get_size( | 1319 | += mem_heap_get_size( |
1772 | 1319 | btr_search_sys->hash_index->heaps[i]); | 1320 | btr_search_sys->hash_index[0] |
1773 | 1321 | ->heaps[i]); | ||
1774 | 1320 | } | 1322 | } |
1775 | 1321 | } | 1323 | } |
1776 | 1324 | btr_search_sys_subtotal *= btr_search_index_num; | ||
1777 | 1322 | 1325 | ||
1778 | 1323 | lock_sys_subtotal = 0; | 1326 | lock_sys_subtotal = 0; |
1779 | 1324 | if (trx_sys) { | 1327 | if (trx_sys) { |
1780 | @@ -1347,13 +1350,15 @@ | |||
1781 | 1347 | " Recovery system %lu \t(%lu + " ULINTPF ")\n", | 1350 | " Recovery system %lu \t(%lu + " ULINTPF ")\n", |
1782 | 1348 | 1351 | ||
1783 | 1349 | (ulong) (btr_search_sys | 1352 | (ulong) (btr_search_sys |
1786 | 1350 | ? (btr_search_sys->hash_index->n_cells | 1353 | ? (btr_search_sys->hash_index[0]->n_cells |
1787 | 1351 | * sizeof(hash_cell_t)) | 1354 | * sizeof(hash_cell_t) |
1788 | 1355 | * btr_search_index_num) | ||
1789 | 1352 | : 0) | 1356 | : 0) |
1790 | 1353 | + btr_search_sys_subtotal, | 1357 | + btr_search_sys_subtotal, |
1791 | 1354 | (ulong) (btr_search_sys | 1358 | (ulong) (btr_search_sys |
1794 | 1355 | ? (btr_search_sys->hash_index->n_cells | 1359 | ? (btr_search_sys->hash_index[0]->n_cells |
1795 | 1356 | * sizeof(hash_cell_t)) | 1360 | * sizeof(hash_cell_t) |
1796 | 1361 | * btr_search_index_num) | ||
1797 | 1357 | : 0), | 1362 | : 0), |
1798 | 1358 | btr_search_sys_subtotal, | 1363 | btr_search_sys_subtotal, |
1799 | 1359 | 1364 | ||
1800 | @@ -1504,21 +1509,23 @@ | |||
1801 | 1504 | buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len); | 1509 | buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len); |
1802 | 1505 | buf_get_total_list_size_in_bytes(&buf_pools_list_size); | 1510 | buf_get_total_list_size_in_bytes(&buf_pools_list_size); |
1803 | 1506 | 1511 | ||
1805 | 1507 | if (btr_search_sys && btr_search_sys->hash_index->heap) { | 1512 | if (btr_search_sys && btr_search_sys->hash_index[0]->heap) { |
1806 | 1508 | mem_adaptive_hash | 1513 | mem_adaptive_hash |
1808 | 1509 | = mem_heap_get_size(btr_search_sys->hash_index->heap); | 1514 | = mem_heap_get_size(btr_search_sys |
1809 | 1515 | ->hash_index[0]->heap); | ||
1810 | 1510 | } else { | 1516 | } else { |
1811 | 1511 | mem_adaptive_hash = 0; | 1517 | mem_adaptive_hash = 0; |
1813 | 1512 | for (i=0; i < btr_search_sys->hash_index->n_sync_obj; i++) { | 1518 | for (i=0; i < btr_search_sys->hash_index[0]->n_sync_obj; i++) { |
1814 | 1513 | mem_adaptive_hash | 1519 | mem_adaptive_hash |
1815 | 1514 | += mem_heap_get_size | 1520 | += mem_heap_get_size |
1817 | 1515 | (btr_search_sys->hash_index->heaps[i]); | 1521 | (btr_search_sys->hash_index[0]->heaps[i]); |
1818 | 1516 | } | 1522 | } |
1819 | 1517 | } | 1523 | } |
1820 | 1518 | if (btr_search_sys) { | 1524 | if (btr_search_sys) { |
1822 | 1519 | mem_adaptive_hash += (btr_search_sys->hash_index->n_cells | 1525 | mem_adaptive_hash += (btr_search_sys->hash_index[0]->n_cells |
1823 | 1520 | * sizeof(hash_cell_t)); | 1526 | * sizeof(hash_cell_t)); |
1824 | 1521 | } | 1527 | } |
1825 | 1528 | mem_adaptive_hash *= btr_search_index_num; | ||
1826 | 1522 | 1529 | ||
1827 | 1523 | mem_dictionary = (dict_sys ? ((dict_sys->table_hash->n_cells | 1530 | mem_dictionary = (dict_sys ? ((dict_sys->table_hash->n_cells |
1828 | 1524 | + dict_sys->table_id_hash->n_cells | 1531 | + dict_sys->table_id_hash->n_cells |
1829 | 1525 | 1532 | ||
1830 | === modified file 'Percona-Server/storage/innobase/sync/sync0sync.cc' | |||
1831 | --- Percona-Server/storage/innobase/sync/sync0sync.cc 2013-08-06 15:16:34 +0000 | |||
1832 | +++ Percona-Server/storage/innobase/sync/sync0sync.cc 2013-08-29 17:07:33 +0000 | |||
1833 | @@ -38,6 +38,7 @@ | |||
1834 | 38 | #include "sync0rw.h" | 38 | #include "sync0rw.h" |
1835 | 39 | #include "buf0buf.h" | 39 | #include "buf0buf.h" |
1836 | 40 | #include "srv0srv.h" | 40 | #include "srv0srv.h" |
1837 | 41 | #include "btr0types.h" | ||
1838 | 41 | #include "buf0types.h" | 42 | #include "buf0types.h" |
1839 | 42 | #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ | 43 | #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ |
1840 | 43 | #ifdef UNIV_SYNC_DEBUG | 44 | #ifdef UNIV_SYNC_DEBUG |
1841 | @@ -1149,7 +1150,6 @@ | |||
1842 | 1149 | case SYNC_ANY_LATCH: | 1150 | case SYNC_ANY_LATCH: |
1843 | 1150 | case SYNC_FILE_FORMAT_TAG: | 1151 | case SYNC_FILE_FORMAT_TAG: |
1844 | 1151 | case SYNC_DOUBLEWRITE: | 1152 | case SYNC_DOUBLEWRITE: |
1845 | 1152 | case SYNC_SEARCH_SYS: | ||
1846 | 1153 | case SYNC_THREADS: | 1153 | case SYNC_THREADS: |
1847 | 1154 | case SYNC_LOCK_SYS: | 1154 | case SYNC_LOCK_SYS: |
1848 | 1155 | case SYNC_LOCK_WAIT_SYS: | 1155 | case SYNC_LOCK_WAIT_SYS: |
1849 | @@ -1182,6 +1182,24 @@ | |||
1850 | 1182 | ut_a(sync_thread_levels_contain(array, SYNC_LOCK_SYS)); | 1182 | ut_a(sync_thread_levels_contain(array, SYNC_LOCK_SYS)); |
1851 | 1183 | } | 1183 | } |
1852 | 1184 | break; | 1184 | break; |
1853 | 1185 | case SYNC_SEARCH_SYS: { | ||
1854 | 1186 | /* Verify the lock order inside the split btr_search_latch | ||
1855 | 1187 | array */ | ||
1856 | 1188 | bool found_current = false; | ||
1857 | 1189 | for (ulint i = 0; i < btr_search_index_num; i++) { | ||
1858 | 1190 | if (btr_search_latch_arr[i] == latch) { | ||
1859 | 1191 | found_current = true; | ||
1860 | 1192 | } else if (found_current) { | ||
1861 | 1193 | ut_ad(!rw_lock_own(btr_search_latch_arr[i], | ||
1862 | 1194 | RW_LOCK_SHARED)); | ||
1863 | 1195 | ut_ad(!rw_lock_own(btr_search_latch_arr[i], | ||
1864 | 1196 | RW_LOCK_EX)); | ||
1865 | 1197 | } | ||
1866 | 1198 | } | ||
1867 | 1199 | ut_ad(found_current); | ||
1868 | 1200 | |||
1869 | 1201 | /* fallthrough */ | ||
1870 | 1202 | } | ||
1871 | 1185 | case SYNC_BUF_FLUSH_LIST: | 1203 | case SYNC_BUF_FLUSH_LIST: |
1872 | 1186 | case SYNC_BUF_POOL: | 1204 | case SYNC_BUF_POOL: |
1873 | 1187 | /* We can have multiple mutexes of this type therefore we | 1205 | /* We can have multiple mutexes of this type therefore we |
1874 | 1188 | 1206 | ||
1875 | === modified file 'Percona-Server/storage/innobase/trx/trx0trx.cc' | |||
1876 | --- Percona-Server/storage/innobase/trx/trx0trx.cc 2013-08-06 15:16:34 +0000 | |||
1877 | +++ Percona-Server/storage/innobase/trx/trx0trx.cc 2013-08-29 17:07:33 +0000 | |||
1878 | @@ -23,6 +23,7 @@ | |||
1879 | 23 | Created 3/26/1996 Heikki Tuuri | 23 | Created 3/26/1996 Heikki Tuuri |
1880 | 24 | *******************************************************/ | 24 | *******************************************************/ |
1881 | 25 | 25 | ||
1882 | 26 | #include "btr0types.h" | ||
1883 | 26 | #include "trx0trx.h" | 27 | #include "trx0trx.h" |
1884 | 27 | 28 | ||
1885 | 28 | #ifdef UNIV_NONINL | 29 | #ifdef UNIV_NONINL |
1886 | 29 | 30 | ||
1887 | === modified file 'Percona-Server/storage/innobase/ut/ut0ut.cc' | |||
1888 | --- Percona-Server/storage/innobase/ut/ut0ut.cc 2013-08-06 15:16:34 +0000 | |||
1889 | +++ Percona-Server/storage/innobase/ut/ut0ut.cc 2013-08-29 17:07:33 +0000 | |||
1890 | @@ -39,6 +39,7 @@ | |||
1891 | 39 | #include <ctype.h> | 39 | #include <ctype.h> |
1892 | 40 | 40 | ||
1893 | 41 | #ifndef UNIV_HOTBACKUP | 41 | #ifndef UNIV_HOTBACKUP |
1894 | 42 | # include "btr0types.h" | ||
1895 | 42 | # include "trx0trx.h" | 43 | # include "trx0trx.h" |
1896 | 43 | # include "ha_prototypes.h" | 44 | # include "ha_prototypes.h" |
1897 | 44 | # include "mysql_com.h" /* NAME_LEN */ | 45 | # include "mysql_com.h" /* NAME_LEN */ |
Same comments about excessive INSERT/SELECT statements as in https:/ /code.launchpad .net/~laurynas- biveinis/ percona- server/ ahi-partitions- 5.6-5.5/ +merge/ 181713.
I haven't reviewed the actual code port yet.