jenkins-bot has submitted this change and it was merged.
Change subject: Fixed redis reconnect handling when passwords are used in
luaEval()
......................................................................
Fixed redis reconnect handling when passwords are used in luaEval()
Change-Id: Ifc974e6787d180f9b14624481ffe7c456f689254
(cherry picked from commit ea86cbb224253efce9951ff37673f6aa0170f990)
---
M includes/clientpool/RedisConnectionPool.php
1 file changed, 30 insertions(+), 1 deletion(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/clientpool/RedisConnectionPool.php
b/includes/clientpool/RedisConnectionPool.php
index f7653eb..c8e98a7 100644
--- a/includes/clientpool/RedisConnectionPool.php
+++ b/includes/clientpool/RedisConnectionPool.php
@@ -283,6 +283,25 @@
}
}
}
+
+ /**
+ * Resend an AUTH request to the redis server (useful after disconnects)
+ *
+ * This method is for internal use only
+ *
+ * @param string $server
+ * @param Redis $conn
+ * @return bool Success
+ */
+ public function reauthenticateConnection( $server, Redis $conn ) {
+ if ( $this->password !== null ) {
+ if ( !$conn->auth( $this->password ) ) {
+ wfDebugLog( 'redis', "Authentication error
connecting to $server" );
+ return false;
+ }
+ }
+ return true;
+ }
}
/**
@@ -324,10 +343,21 @@
public function luaEval( $script, array $params, $numKeys ) {
$sha1 = sha1( $script ); // 40 char hex
$conn = $this->conn; // convenience
+ $server = $this->server; // convenience
// Try to run the server-side cached copy of the script
$conn->clearLastError();
$res = $conn->evalSha( $sha1, $params, $numKeys );
+ // If we got a permission error reply that means that (a) we
are not in
+ // multi()/pipeline() and (b) some connection problem likely
occured. If
+ // the password the client gave was just wrong, an exception
should have
+ // been thrown back in getConnection() previously.
+ if ( preg_match( '/^ERR operation not permitted\b/',
$conn->getLastError() ) ) {
+ $this->pool->reauthenticateConnection( $server, $conn );
+ $conn->clearLastError();
+ $res = $conn->eval( $script, $params, $numKeys );
+ wfDebugLog( 'redis', "Used automatic re-authentication
for Lua script $sha1." );
+ }
// If the script is not in cache, use eval() to retry and cache
it
if ( preg_match( '/^NOSCRIPT/', $conn->getLastError() ) ) {
$conn->clearLastError();
@@ -336,7 +366,6 @@
}
if ( $conn->getLastError() ) { // script bug?
- $server = $this->server;
wfDebugLog( 'redis', "Lua script error on server
$server: " . $conn->getLastError() );
}
--
To view, visit https://gerrit.wikimedia.org/r/93898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc974e6787d180f9b14624481ffe7c456f689254
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.23wmf1
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits