Unnecessary overhead from persistent adaptive hash index latches
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MySQL Server |
Unknown
|
Unknown
|
|||
Percona Server moved to https://jira.percona.com/projects/PS |
Fix Released
|
High
|
Alexey Kopytov | ||
5.1 |
Invalid
|
Undecided
|
Unassigned | ||
5.5 |
Fix Released
|
High
|
Alexey Kopytov | ||
5.6 |
Fix Released
|
High
|
Alexey Kopytov |
Bug Description
The server and InnoDB implement the following logic with respect to AHI latches acquired in row_search_
1. When row_search_
2. The latch is not normally released when InnoDB returns the control back to the server, i.e. is kept across multiple server calls into InnoDB.
3. The server may force InnoDB to release that latch later via ha_release_
4. The latch is also released by InnoDB on table open/close or transaction start/commit/
5. The latch is also released by InnoDB if it detects there are X waiters on the latch.
6. In which case it also releases the S latch acquired by row_search_
So it's quite a lot of work to have a persistent S latch and avoid contention on it at the same time. The question is why do we need to have a persistent lock in the first place. Comments in ha_release_
/**
@details
This function should be called when MySQL sends rows of a SELECT result set
or the EOF mark to the client. It releases a possible adaptive hash index
S-latch held by thd in InnoDB and also releases a possible InnoDB query
FIFO ticket to enter InnoDB. To save CPU time, InnoDB allows a thd to
keep them over several calls of the InnoDB handler interface when a join
is executed. But when we let the control to pass to the client they have
to be released because if the application program uses mysql_use_result(),
it may deadlock on the S-latch if the application on another connection
performs another SQL query. In MySQL-4.1 this is even more important because
there a connection can have several SELECT queries open at the same time.
*/
It is unclear how much CPU time is saved in reality, given all the complications to avoid contention on the latch.
Also with AHI partitioning we have many latches to take care of, so the above logic becomes quite complicated, fragile, and is likely the reason for bugs like bug #1100760.
This report is to disable that persistent latches functionality.
Related branches
- Laurynas Biveinis (community): Approve
-
Diff: 1935 lines (+448/-373) (has conflicts)22 files modifiedPercona-Server/mysql-test/r/percona_bug1218330.result (+8/-0)
Percona-Server/mysql-test/t/percona_bug1218330-master.opt (+1/-0)
Percona-Server/mysql-test/t/percona_bug1218330.test (+42/-0)
Percona-Server/storage/innobase/btr/btr0cur.c (+6/-5)
Percona-Server/storage/innobase/btr/btr0sea.c (+119/-139)
Percona-Server/storage/innobase/buf/buf0buf.c (+1/-3)
Percona-Server/storage/innobase/dict/dict0boot.c (+8/-0)
Percona-Server/storage/innobase/dict/dict0dict.c (+3/-1)
Percona-Server/storage/innobase/dict/dict0load.c (+2/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+11/-6)
Percona-Server/storage/innobase/ibuf/ibuf0ibuf.c (+2/-0)
Percona-Server/storage/innobase/include/btr0sea.h (+36/-15)
Percona-Server/storage/innobase/include/btr0sea.ic (+67/-35)
Percona-Server/storage/innobase/include/btr0types.h (+6/-7)
Percona-Server/storage/innobase/include/buf0buf.h (+0/-1)
Percona-Server/storage/innobase/include/dict0mem.h (+4/-0)
Percona-Server/storage/innobase/include/trx0trx.h (+7/-5)
Percona-Server/storage/innobase/include/trx0trx.ic (+13/-0)
Percona-Server/storage/innobase/row/row0mysql.c (+6/-2)
Percona-Server/storage/innobase/row/row0sel.c (+36/-97)
Percona-Server/storage/innobase/srv/srv0srv.c (+64/-36)
Percona-Server/storage/innobase/trx/trx0trx.c (+6/-21)
- Laurynas Biveinis (community): Approve
-
Diff: 1957 lines (+482/-381)25 files modifiedPercona-Server/mysql-test/r/percona_bug1218330.result (+14/-0)
Percona-Server/mysql-test/t/percona_bug1218330-master.opt (+1/-0)
Percona-Server/mysql-test/t/percona_bug1218330.test (+72/-0)
Percona-Server/storage/innobase/btr/btr0cur.cc (+7/-7)
Percona-Server/storage/innobase/btr/btr0sea.cc (+109/-132)
Percona-Server/storage/innobase/buf/buf0buf.cc (+0/-2)
Percona-Server/storage/innobase/dict/dict0boot.cc (+6/-0)
Percona-Server/storage/innobase/dict/dict0dict.cc (+5/-3)
Percona-Server/storage/innobase/dict/dict0load.cc (+1/-0)
Percona-Server/storage/innobase/ha/ha0ha.cc (+2/-2)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+21/-19)
Percona-Server/storage/innobase/handler/xtradb_i_s.cc (+35/-33)
Percona-Server/storage/innobase/ibuf/ibuf0ibuf.cc (+2/-0)
Percona-Server/storage/innobase/include/btr0sea.h (+35/-9)
Percona-Server/storage/innobase/include/btr0sea.ic (+66/-11)
Percona-Server/storage/innobase/include/btr0types.h (+7/-6)
Percona-Server/storage/innobase/include/buf0buf.h (+0/-2)
Percona-Server/storage/innobase/include/dict0mem.h (+4/-0)
Percona-Server/storage/innobase/include/trx0trx.h (+7/-5)
Percona-Server/storage/innobase/include/trx0trx.ic (+5/-12)
Percona-Server/storage/innobase/row/row0ftsort.cc (+3/-0)
Percona-Server/storage/innobase/row/row0sel.cc (+32/-91)
Percona-Server/storage/innobase/srv/srv0srv.cc (+42/-44)
Percona-Server/storage/innobase/sync/sync0sync.cc (+3/-3)
Percona-Server/storage/innobase/trx/trx0trx.cc (+3/-0)
tags: | added: ahi-partitions |
Percona now uses JIRA for bug reports so this bug report is migrated to: https:/ /jira.percona. com/browse/ PS-715