Page MenuHomePhabricator

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

Description

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(),
            ],
            __METHOD__
        );
    }

    $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
https://de.wikipedia.org/w/index.php?title=Wikipedia:Fragen_zur_Wikipedia&oldid=159569789#Verschieben

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

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

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

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

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

Hopefully better now