Page MenuHomePhabricator

WikiPage::insertRedirectEntry query could be slow or timeouts
Closed, ResolvedPublic


WikiPage::insertRedirectEntry queries could take sixteen seconds to run, or timeout when done on de.wikipedia, a wiki hosted on s3.

A search on *insertRedirectEntry* on logstash gives an idea of the frequency of the issue, strangely apparently always on dewiki.

This creates user facing issue when it timeouts, as this method is for example triggered on page move, when a redirect is let to the former, preventing the move to complete.

Relevant method code

 * Insert or update the redirect table entry for this page to indicate it redirects to $rt
 * @param Title $rt Redirect target
 * @param int|null $oldLatest Prior page_latest for check and set
public function insertRedirectEntry( Title $rt, $oldLatest = null ) {
    $dbw = wfGetDB( DB_MASTER );
    $dbw->startAtomic( __METHOD__ );

    if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) {
        $dbw->replace( 'redirect',
            [ 'rd_from' ],
                'rd_from' => $this->getId(),
                'rd_namespace' => $rt->getNamespace(),
                'rd_title' => $rt->getDBkey(),
                'rd_fragment' => $rt->getFragment(),
                'rd_interwiki' => $rt->getInterwiki(),

    $dbw->endAtomic( __METHOD__ );

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 10 2016, 5:29 PM

Maybe related:

[WCSnOQpAMFUAAGnTAbEAAAAE] 2016-11-10 16:58:50: Fataler Ausnahmefehler des Typs „DBQueryError“

Reported at german village pump

Change 320862 had a related patch set uploaded (by Aaron Schulz):
Make insertRedirectEntry() use upset() to reduce contention

Change 320862 merged by jenkins-bot:
Make insertRedirectEntry() use upsert() to reduce contention

Umherirrender closed this task as Resolved.Nov 25 2016, 8:08 PM
Umherirrender claimed this task.

Hopefully better now