Page MenuHomePhabricator

New User hook broken for PG, breaks normal logging
Closed, ResolvedPublic

Description

Author: overlordq

Description:
CheckUser is broken wrt Postgres and the new user hook. PG has a foreign key constraint on cuc_page_id to an entry in the page table, however on new users it tries to enter page id 0 which doesn't exist. I'm fairly sure this worked fine before, so I dont know what or when the behavior changes.

This completely breaks the new user log.

Details

Reference
bz34372

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.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:12 AM
bzimport set Reference to bz34372.
bzimport added a subscriber: Unknown Object (MLST).

Looks like it is a regression in the way we pass page_id to some new user hook.

Added to 1.19 tracking per bugmeister's email.

Can we check how much regression is this?

PostgreSQL allows NULL in cuc_page_id but does not allow 0 because of constraint.

MySQL the reverse - allows 0 but it's NOT NULL.

We even explicitly insert zero in the new extension code, but I am not sure what's coming via hooks. We are also using some other hooks (e.g. bug 19963
fixed with r88258 as well as some new hooks), so probably it's best to detect zero and covert it to NULL.

I would tend to change cuc_page_id to NULL on MySQL (yeah, on this means on Wikimedia too) plus fix the code where necessary.

Is this okay with everyone?

Asher - could you possibly to comment on this schema change?12

afeldman wrote:

I think having cuc_page_id default to NULL makes more sense, and enwiki currently has slightly over 1 million rows in cu_changes where cuc_page_id = 0, out of ~16mil rows total.

That said, it is only until relatively recently (in the history of mysql) that NULL values have been allowed for integer types.

http://bugs.mysql.com/bug.php?id=44243

That's why you'll see DEFAULT NULL in the char fields, but NOT NULL DEFAULT 0 for the ints.

Changing this is ok wrt the version of mysql in production at wmf, but would require increasing the minimum required version of mediawiki beyond what it currently is.

Krinkle removed a project: Future-Release.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Aklapper lowered the priority of this task from High to Low.Jan 16 2015, 6:50 PM
Aklapper subscribed.

Task was set to high priority three years ago; no news since two and a half years.
Setting to low priority to reflect the obvious reality here.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.