Page MenuHomePhabricator

Sqlite category table contains duplicates in unit tests
Open, MediumPublic

Description

A unit test https://gerrit.wikimedia.org/r/#/c/48098/ fails on Sqlite backend, but functions properly with MySql backend.

The test creates two pages with the [[Category:AQBT-Cat]], and tests that a call to api api.php?action=query&list=allcategories&acprefix=AQBT- returns only one value.

With sqlite, two identical values are returned.


Version: unspecified
Severity: normal

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:13 AM
bzimport set Reference to bz44790.
bzimport added a subscriber: Unknown Object (MLST).

That sounds like table category gets two entries with cat_pages=1 instead of one with cat_pages=2 (output lags this info, can you add acprop=size?), sounds impossible due to a unique index there

I suspect the indexes are not created when unit test harness clones DBs, but have no easy way to very this. The strange thing is that this bug only occurs with categories, not with page links or templates

That is bug 37702

There is a difference, because here a extra table category is used to count the entries. There is no table template or link to count the entries per template/link.

Have a look at WikiPage::updateCategoryCounts, why you get duplicates.

(In reply to comment #3)

That is bug 37702

db, but the unit tests work when testing with MySql, and all queries are identical, which makes me believe that the clone table without "unique" index is what causes this issue. Setting dependent bug to 37702.

Maybe foreign keys are duplicated on mysql and not on sqlite.

Have a look at duplicateTableStructure of DatabaseSqlite or DatabaseMysql to check that

The relying on the unique index changed with I7e6d07e42cc06cedbd9d10ed9f276f20636dc222

Change 48098 had a related patch set uploaded (by Jdlrobson):
API bug with sqlite returns duplicate categories

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

Change 48098 abandoned by Krinkle:
API bug with sqlite returns duplicate categories

Reason:
Inactive patch. Can be re-opened or re-used later.

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