When the query to rebuild the recentchanges data (from RebuildRecentchanges::rebuildRecentChangesTablePass1) arrived on db1065 and db1066 (API servers) due to a missing INDEX on rev_timestamp the execution plan was a full table scan and would have taken the replication stuck for a very long time. It was reading ~1100 row/s.
So we have decided to kill it and skip it in the replication.
The reason behind this decision:
- Not user facing (at least for now)
- Replica was stuck and estimation of completion was very long
- The 2 servers are in eqiad (passive DC today) and dedicated to API
- The inserted data on other servers were just 2682 rows, we can backfill them tomorrow manually or with pt-table-checksum
- This is temporary data that in any case will go away in ~1-3 months and seems that will not be visible anyway due to application layer filter limitation to 5000 changes given that this is enwiki
The killed query was:
INSERT /* RebuildRecentchanges::rebuildRecentChangesTablePass1 */ INTO `recentchanges` (rc_timestamp,rc_user,rc_user_text,rc_namespace,rc_title,rc_comment,rc_minor,rc_bot,rc_new,rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type,rc_source,rc_deleted) SELECT rev_timestamp,rev_user,rev_user_text,page_namespace,page_title,rev_comment,rev_minor_edit,0,page_is_new,page_id,rev_id,0, (CASE WHEN page_is_new != 0 THEN 1 ELSE 0 END) , (CASE WHEN page_is_new != 0 THEN 'mw.new' ELSE 'mw.edit' END) ,rev_deleted FROM `page`,`revision` WHERE (rev_timestamp > '20160419144741') AND (rev_timestamp < '20160419151018') AND (rev_page=page_id) ORDER BY rev_timestamp DESC
Execution plan
+------+-------------+----------+------+------------------------------------------------+-------------+---------+---------------------+----------+----------+---------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+----------+------+------------------------------------------------+-------------+---------+---------------------+----------+----------+---------------------------------+ | 1 | SIMPLE | page | ALL | PRIMARY | NULL | NULL | NULL | 41618662 | 100.00 | Using temporary; Using filesort | | 1 | SIMPLE | revision | ref | rev_page_id,page_timestamp,page_user_timestamp | rev_page_id | 4 | enwiki.page.page_id | 6 | 100.00 | Using where | +------+-------------+----------+------+------------------------------------------------+-------------+---------+---------------------+----------+----------+---------------------------------+