Blame SOURCES/bz1400103-redis-notify-clients-of-master-being-demoted.patch

be1049
From f1c2249ef5e8524ddb986f0df879d5f18e935da3 Mon Sep 17 00:00:00 2001
4c01c1
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
be1049
Date: Fri, 20 Jan 2017 09:17:15 +0100
4c01c1
Subject: [PATCH] redis: use "CLIENT KILL type normal" to notify clients of
4c01c1
 master being demoted
4c01c1
4c01c1
---
be1049
 heartbeat/redis | 11 +++++++++++
be1049
 1 file changed, 11 insertions(+)
4c01c1
4c01c1
diff --git a/heartbeat/redis b/heartbeat/redis
be1049
index 1ea0025..d08e57a 100755
4c01c1
--- a/heartbeat/redis
4c01c1
+++ b/heartbeat/redis
be1049
@@ -436,6 +436,11 @@ function demote() {
be1049
 	local master_host
be1049
 	local master_port
4c01c1
 
be1049
+	# client kill is only supported in Redis 2.8.12 or greater
be1049
+	version=$(redis_client -v | awk '{print $NF}')
be1049
+	ocf_version_cmp "$version" "2.8.11"
be1049
+	client_kill=$?
be1049
+
be1049
 	CHECK_SLAVE_STATE=1
be1049
 	monitor
be1049
 	status=$?
be1049
@@ -478,9 +483,15 @@ function demote() {
be1049
 	while true; do 
be1049
 		# Wait infinite if replication is syncing
be1049
 		# Then start/demote operation timeout determines timeout
be1049
+		if [ "$client_kill" -eq 2 ]; then
be1049
+			redis_client CLIENT PAUSE 2000
be1049
+		fi
be1049
 		monitor
be1049
 		status=$?
be1049
 		if (( status == OCF_SUCCESS )); then
be1049
+			if [ "$client_kill" -eq 2 ]; then
be1049
+				redis_client CLIENT KILL type normal
be1049
+			fi
be1049
 			return $OCF_SUCCESS
be1049
 		fi
be1049