Spotted this on commonswiki master:
SELECT /* LocalFileDeleteBatch::getHashes */ oi_archive_name, oi_sha1 FROM oldimage WHERE oi_archive_name IN ('20140306203724!Copa_América_Argentina_2011_(logo).png', '20140306204156!Copa_América_Argentina_2011_(logo).png')
Commons oldimage has millions of rows, and this does a table scan because oi_archive_name is only indexed in second position:
KEY oi_name_archive_name (oi_name,oi_archive_name(14))
This transaction was also holding locks on page table presumably from an earlier query. Those locks caused a number of other file-upload transaction to exceed innodb_lock_wait_timeout.
tendril> select * from innodb_locks_log where lock_trx_id = 'AB64BF626'\G
- 1. row ******* stamp: 2014-03-07 05:51:47 server_id: 1060 lock_id: AB64BF626:0:34662177:177
lock_trx_id: AB64BF626
lock_mode: X lock_type: RECORD
lock_table: commonswiki.page
lock_index: name_title
lock_space: 0
lock_page: 34662177 lock_rec: 177 lock_data: 6, 0x436F70615F416DC3A9726963615F417267656E74696E615F323031315F286C6F676F292E706E67
... more similar locks ...
16 rows in set (0.35 sec)
Therefore:
- oi_archive_name deserves an index, or can oi_name be included in the query?
- oldimage deserves a primary key to make online schema changes possible.
- Can the query go to a slave?
Version: 1.23.0
Severity: major