jenkins-bot has submitted this change and it was merged.

Change subject: Removed "page-lastedit" cache key trick from WikiPage
......................................................................


Removed "page-lastedit" cache key trick from WikiPage

* Just rely on chronology protected and edit conflict handling.
  The time a user spends looking at and editing pages is larger
  than any normal slave lag anyway.
* However make sure that pages just made in the request are visible.
* In "master" datacenters, the slave lag will low anyway, and 
  callers make use of $flags when needed. In other datacenters,
  the cache will itself be subject to lag anyway.
* Logging (DBPerformance log) shows this case is very rarely
  hit anyway.

Change-Id: If34d67c02f9a7bf0a506ee8f3990697eb403a710
---
M includes/page/WikiPage.php
1 file changed, 6 insertions(+), 32 deletions(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index d96e271..f2a3c79 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -367,14 +367,12 @@
                        $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), 
$this->mTitle );
                } elseif ( $from === self::READ_NORMAL ) {
                        $data = $this->pageDataFromTitle( wfGetDB( DB_SLAVE ), 
$this->mTitle );
-                       // Use a "last rev inserted" timestamp key to diminish 
the issue of slave lag.
-                       // Note that DB also stores the master position in the 
session and checks it.
-                       $touched = $this->getCachedLastEditTime();
-                       if ( $touched ) { // key set
-                               if ( !$data || $touched > wfTimestamp( TS_MW, 
$data->page_touched ) ) {
-                                       $from = self::READ_LATEST;
-                                       $data = $this->pageDataFromTitle( 
wfGetDB( DB_MASTER ), $this->mTitle );
-                               }
+                       if ( !$data
+                               && wfGetLB()->getServerCount() > 1
+                               && wfGetLB()->hasOrMadeRecentMasterChanges()
+                       ) {
+                               $from = self::READ_LATEST;
+                               $data = $this->pageDataFromTitle( wfGetDB( 
DB_MASTER ), $this->mTitle );
                        }
                } else {
                        // No idea from where the caller got this data, assume 
slave database.
@@ -808,29 +806,6 @@
                } else {
                        return false;
                }
-       }
-
-       /**
-        * Get the cached timestamp for the last time the page changed.
-        * This is only used to help handle slave lag by comparing to 
page_touched.
-        * @return string MW timestamp
-        */
-       protected function getCachedLastEditTime() {
-               global $wgMemc;
-               $key = wfMemcKey( 'page-lastedit', md5( 
$this->mTitle->getPrefixedDBkey() ) );
-               return $wgMemc->get( $key );
-       }
-
-       /**
-        * Set the cached timestamp for the last time the page changed.
-        * This is only used to help handle slave lag by comparing to 
page_touched.
-        * @param string $timestamp
-        * @return void
-        */
-       public function setCachedLastEditTime( $timestamp ) {
-               global $wgMemc;
-               $key = wfMemcKey( 'page-lastedit', md5( 
$this->mTitle->getPrefixedDBkey() ) );
-               $wgMemc->set( $key, wfTimestamp( TS_MW, $timestamp ), 60 * 15 );
        }
 
        /**
@@ -1304,7 +1279,6 @@
                if ( $result ) {
                        $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect 
);
                        $this->setLastEdit( $revision );
-                       $this->setCachedLastEditTime( $now );
                        $this->mLatest = $revision->getId();
                        $this->mIsRedirect = (bool)$rt;
                        // Update the LinkCache.

-- 
To view, visit https://gerrit.wikimedia.org/r/200761
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If34d67c02f9a7bf0a506ee8f3990697eb403a710
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to