Page MenuHomePhabricator

category_title index for Pg is wrong?
Closed, InvalidPublic

Description

Found "duplicate key value violates unique constraint "category_title"" in my logs while doing importDump and seeing that it is defined in tables.sql as

CREATE UNIQUE INDEX category_title ON category(cat_title);

I thought there might be something wrong with the dump, but grepping for the title ("Articles_with_example_pseudocode") only found the following in my logs:

LOG: statement: INSERT /* LinksUpdate::incrTableUpdate 127.0.0.1 */ INTO categorylinks (cl_from,cl_to,cl_sortkey,cl_timestamp,cl_sortkey_prefix,cl_collation,cl_type) VALUES ('439','Articles_with_example_pseudocode','ALGORITHMS FOR CALCULATING VARIANCE
LOG: statement: SELECT /* LinksUpdate::invalidatePages 127.0.0.1 */ page_id FROM page WHERE page_namespace = '14' AND (page_title IN ('Statistical_algorithms','Statistical_deviation_and_dispersion','Articles_with_example_pseudocode')) AND (page_touched < '2011-02-09 18:07:14 GMT')
LOG: statement: INSERT /* Article::updateCategoryCounts 127.0.0.1 */ INTO category (cat_id,cat_title) VALUES ('1586','Articles_with_example_pseudocode')
STATEMENT: INSERT /* Article::updateCategoryCounts 127.0.0.1 */ INTO category (cat_id,cat_title) VALUES ('1586','Articles_with_example_pseudocode')
LOG: statement: UPDATE /* Article::updateCategoryCounts 127.0.0.1 */ category SET cat_pages = cat_pages + 1 WHERE cat_title IN ('Statistical_algorithms','Statistical_deviation_and_dispersion','Articles_with_example_pseudocode')

(The error occured on the "category" INSERT statement)


Version: 1.18.x
Severity: normal

Details

Reference
bz27285

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
InvalidNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:21 PM
bzimport set Reference to bz27285.
bzimport added a subscriber: Unknown Object (MLST).

I'm pretty sure the index itself is not the problem, as this is simply copied from the original MySQL tables.sql nearly verbatim.

This is because we have INSERT IGNORE emulation there, so the error should be ignored. The debug log should say:

SQL ERROR (ignored): ....

If something wrong still happens, please update to r113534 and see if it got better; if not please include

$wgShowExceptionDetails = true;
$wgShowSQLErrors = true;
$wgShowDBErrorBacktrace = true;
$wgDebugDumpSql = true;
$wgDebugDBTransactions = true;

in your LocalSettings.php

Jdforrester-WMF subscribed.

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