Page MenuHomePhabricator

change_tag doesn't have a primary key
Closed, ResolvedPublic

Description

It needs one.

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

TTO created this task.Jan 11 2016, 9:41 AM
TTO updated the task description. (Show Details)
TTO raised the priority of this task from to Normal.
TTO claimed this task.
TTO added subscribers: Aklapper, jcrespo, TTO, Legoktm.
Danny_B moved this task from Unsorted to Add / Create on the Schema-change board.Apr 29 2016, 10:28 PM

Change 304165 had a related patch set uploaded (by TTO):
Add primary key to change_tag and tag_summary tables

https://gerrit.wikimedia.org/r/304165

So what I asked on the ticket is a simple, one line justification of "a new auto_increment column is the best option for a primary key because...".

TTO added a comment.Oct 2 2016, 10:06 AM

I think I answered that quite extensively on the patch? Or did you want some more info?

TTO added a comment.Oct 2 2016, 10:09 AM

Just reposting my comment here for posterity:

I don't think converting any of the existing keys will work, as the contents of the tables generally look like this:

$ MariaDB [enwiki_p]> (select * from change_tag where ct_log_id is null limit 1) union all (select * from change_tag where ct_rc_id is null limit 1) union all (select * from change_tag where ct_rev_id is null limit 1);
+-----------+-----------+-----------+------------------+-----------+
| ct_rc_id  | ct_log_id | ct_rev_id | ct_tag           | ct_params |
+-----------+-----------+-----------+------------------+-----------+
| 774304154 |      NULL | 690405091 | End of page text | NULL      |
|      NULL |      NULL | 591814806 | WPCleaner        | NULL      |
| 681941033 |  59010411 |      NULL | HHVM             | NULL      |
+-----------+-----------+-----------+------------------+-----------+
3 rows in set (0.01 sec) 

Note all the NULLs in various places. The tag_summary table looks similar.

It would most likely work if we had a primary key on (ct_rc_id,ct_rev_id,ct_log_id,ct_tag), but that is a very unwieldy primary key, and I think you are trying to get rid of such abominations.

Thank you @TTO, I could not find it on the gerrit comments. Too many alters to review. Copying it here (or alternatively, on the gerrit summary it would have been ok) makes it clearer to me.

Here you have my +1.

Change 304165 merged by jenkins-bot:
Add primary key to change_tag and tag_summary tables

https://gerrit.wikimedia.org/r/304165

Paladox added a subscriber: Paladox.Nov 6 2016, 1:13 PM

Can this task be closed as resolved? The patch was merged.

TTO closed this task as Resolved.Dec 14 2016, 1:45 PM