Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77562
Change subject: Attempt to have more rigorous clearing of image redirect cache
......................................................................
Attempt to have more rigorous clearing of image redirect cache
Instead of just clearing the cache, attempt to repopulate it with
new values during page move. This will hopefully prevent issues
with a lagged slave. (I'm assuming that you can't have similar
"lag" issues with memcache. Hopefully a reviewer can confirm
that that is a good assumption.)
This is an attempt to fix bug 52200. I'm not sure if it will actually
fix the bug, as I'm not sure about the cause, nor can I really
reproduce the bug to test. (These are never good signs). I originally
assumed I couldn't reproduce bug locally, due to lack of replag, but
the bug does not appear on enwikipedia either, which is rather odd.
However, I think this commit might make sense nonetheless even
without the context of that bug.
Change-Id: I0941c93b76fb0aa8eedb883a3ed1167c6e14d0c0
---
M includes/WikiPage.php
M includes/filerepo/FileRepo.php
M includes/filerepo/LocalRepo.php
M includes/specials/SpecialMovepage.php
4 files changed, 42 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/62/77562/1
diff --git a/includes/WikiPage.php b/includes/WikiPage.php
index 9d61abc..19d71a1 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -1332,7 +1332,11 @@
}
if ( $this->getTitle()->getNamespace() == NS_FILE ) {
-
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect(
$this->getTitle() );
+ if ( $isRedirect && $redirectTitle->getNamespace() ===
NS_FILE ) {
+
RepoGroup::singleton()->getLocalRepo()->imageRedirectSetCache(
$this->getTitle(), $redirectTitle );
+ } else {
+
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect(
$this->getTitle() );
+ }
}
wfProfileOut( __METHOD__ );
diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php
index bc1ad91..8ce34ea 100644
--- a/includes/filerepo/FileRepo.php
+++ b/includes/filerepo/FileRepo.php
@@ -1599,6 +1599,21 @@
public function invalidateImageRedirect( Title $title ) {}
/**
+ * Sets the image redirect cache to a specific value
+ *
+ * Used instead of invalidateImageRedirect to avoid issues
+ * with lagged db slaves. As a fallback, will invalidate
+ * the cache, if setting to a specific value is not
+ * supported.
+ *
+ * @param $old Title The image that is the redirect
+ * @param $target Title The target of the redirect
+ */
+ function imageRedirectSetCache( Title $old, Title $target ) {
+ $this->invalidateImageRedirect( $old );
+ }
+
+ /**
* Get the human-readable name of the repo
*
* @return string
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index 549be40..a8c5a98 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -340,6 +340,7 @@
/**
* Invalidates image redirect cache related to that image
*
+ * @note May suffer problems with lagged slaves. See
imageRedirectSetCache
* @param $title Title of page
* @return void
*/
@@ -350,4 +351,25 @@
$wgMemc->delete( $memcKey );
}
}
+
+ /**
+ * Sets the image redirect cache to a specific value
+ *
+ * Used instead of invalidateImageRedirect to avoid issues
+ * with lagged db slaves.
+ *
+ * @param $old Title The image that is the redirect
+ * @param $target Title The target of the redirect
+ * @return void
+ */
+ function imageRedirectSetCache( Title $old, Title $target ) {
+ global $wgMemc;
+ $old = File::normalizeTitle( $old, 'exception' );
+ $target = File::normalizeTitle( $target, 'exception' );
+
+ $memcKey = $this->getSharedCacheKey( 'image_redirect', md5(
$old->getDBkey() ) );
+ if ( $memcKey ) {
+ $wgMemc->set( $memcKey, $target->getDBkey(), 86400 );
+ }
+ }
}
diff --git a/includes/specials/SpecialMovepage.php
b/includes/specials/SpecialMovepage.php
index 0e342cc..1dc4244 100644
--- a/includes/specials/SpecialMovepage.php
+++ b/includes/specials/SpecialMovepage.php
@@ -692,13 +692,6 @@
# Deal with watches (we don't watch subpages)
WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user );
WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user );
-
- # Re-clear the file redirect cache, which may have been
polluted by
- # parsing in messages above. See CR r56745.
- # @todo FIXME: Needs a more robust solution inside FileRepo.
- if ( $ot->getNamespace() == NS_FILE ) {
-
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $ot );
- }
}
function showLogFragment( $title ) {
--
To view, visit https://gerrit.wikimedia.org/r/77562
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0941c93b76fb0aa8eedb883a3ed1167c6e14d0c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits