Add new Category::refreshCountsIfSmall() method that will do a non-locking
SELECT with LIMIT before deciding whether to do a full locking SELECT and
refresh. Call this from LinksDeletionUpdate.
Bug: T18036
Change-Id: I9de8311565988453b8e29a7f3d95d758182fcec1
We've noticed a large increase in deadlocks between
LinksDeletionUpdate deleting categorylinks rows and
Category::refreshCounts() trying to update the category table.
My best guess as to what's going on there is that LinksDeletionUpdate
locks the category row via the call to WikiPage::updateCategoryCounts()
then the categorylinks rows via its own deletions, while Category first
locks the categorylinks rows (in share mode) and then the category row
when it tries to update or delete it.
To break the deadlock, let's have Category do a SELECT FOR UPDATE on the
category row first before it locks the categorylinks rows.
Bug: T195397
Change-Id: Ie11baadf2ff0ba2afbc86b10bc523525c570a490
LOCK IN SHARE MODE is not allowed with aggregation on postgres/oracle.
Split out the locking and aggregation into two separate queries.
Change-Id: I7f8d113fb678b368437dad84bdb93e81db314cd5
The refresh method uses the initialize() method, which itself
might trigger the refresh method again after the row is created.
Change-Id: I6702bebea66fcb8b94cd2e6a496e55f52fa70b69
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.
Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.
Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.
This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.
Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.
The old constant is an alias now.
Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
A "currently-existing category" is defined as a category that either
contains any pages or has a description page. Thus:
* Category::initialize() now schedules an update to insert a row if the
title exits but the row is missing.
* Category::refreshCounts() now removes the row if the title doesn't
exist and the category is empty.
* WikiPage::onArticleCreate() loads the Category object, to trigger
bullet #1.
* WikiPage::updateCategoryCounts() refreshes the counts if it results in
the row showing 0 pages, to trigger bullet #2.
* LinksDeletionUpdate refreshes the counts if the row shows 0 pages, to
trigger bullet #2.
A maintenance script is provided to update the category table for this
new definition.
Bug: T28411
Bug: T50824
Change-Id: I0f0adf124c181ae5d3c7c95b3b5fb275a725794c
Currently, INSERT...ON DUPLICATE KEY UPDATE is used to update the page
counts in the category table. However, MySQL 5.1.22 and newer, by default,
increment the counter for cat_id before checking for duplicate key errors.
This creates many gaps in the cat_id sequence.
To avoid this, check for existing category rows, and instead UPDATE any
that were found. It is hoped that the extra queries will not significantly
harm performance.
Change-Id: Ic2ab9ff14f04a0c7ea90a5b6756cade0c78e2885
This doesn't completely address the TODO comment. However, I intend
to finish doing so in a separate change.
Change-Id: I71c6dafd4223d79a0153fa8ce7cb0ee1354c0ec6
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.
Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.
Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.
Change-Id: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
ERROR: Closing brace must be on a line by itself
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore
- For non-empty scopes it means the closing brace must be on a separate
line. This is already the case in most classes in some cases the "lazy
closing" is still used.
array(
'x' ); // Moved } to next line
function () { return 'x'; } // Moved } to next line
case 1:
stuff; break; // Moved break to next line
- For empty function it serves as a visual distinction between there not
being a scope block / function body and there being an empty function
body.
function foo(); // No body
function foo() {} // Empty body - violation
function bar() { // Empty body corrected
}
Change-Id: I0310ec379c6d41cc7d483671994d027a49f32164
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls
Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"
Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
This introduce the syntax from aliased table names for aliased field
names into the abstract database layer:
array( 'alias' => 'field' ) gives 'field AS alias'
This patch also includes changes to query pages, api and some more
places to show, how the new syntax looks in "production".
This allow us to remove the "AS" for Non-PostgreSQL databases, if we
want that.
Change-Id: I5f0de1c2f29092c173aec3de93ffdef436799e8d