Blame SOURCES/bz1732867-CTDB-3-fixes.patch

b4b3ce
From 8c61f2019d11781b737251b5cf839437b25fc53f Mon Sep 17 00:00:00 2001
b4b3ce
From: David Disseldorp <ddiss@suse.de>
b4b3ce
Date: Wed, 25 Jul 2018 23:15:10 +0200
b4b3ce
Subject: [PATCH 1/3] CTDB: fix incorrect db corruption reports (bsc#1101668)
b4b3ce
b4b3ce
If a database was disconnected during an active transaction, then
b4b3ce
tdbdump may fail with e.g.:
b4b3ce
> /usr/bin/tdbdump /var/lib/ctdb/persistent/secrets.tdb.1
b4b3ce
Failed to open /var/lib/ctdb/persistent/secrets.tdb.1
b4b3ce
tdb(/var/lib/ctdb/persistent/secrets.tdb.1): FATAL:
b4b3ce
tdb_transaction_recover: attempt to recover read only database
b4b3ce
b4b3ce
This does *not* indicate corruption, only that tdbdump, which opens the
b4b3ce
database readonly, isn't able to perform recovery.
b4b3ce
b4b3ce
Using tdbtool check, instead of tdbdump, passes:
b4b3ce
> tdbtool /var/lib/ctdb/persistent/secrets.tdb.1 check
b4b3ce
tdb_transaction_recover: recovered 2146304 byte database
b4b3ce
Database integrity is OK and has 2 records.
b4b3ce
b4b3ce
Drop the tdbdump checks, and instead rely on the core ctdb event script,
b4b3ce
which performs the same checks with tdbtool.
b4b3ce
b4b3ce
Signed-off-by: David Disseldorp <ddiss@suse.de>
b4b3ce
---
b4b3ce
 heartbeat/CTDB.in | 18 ++++--------------
b4b3ce
 1 file changed, 4 insertions(+), 14 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/CTDB.in b/heartbeat/CTDB.in
b4b3ce
index 1456ea32b..28e58cea0 100755
b4b3ce
--- a/heartbeat/CTDB.in
b4b3ce
+++ b/heartbeat/CTDB.in
b4b3ce
@@ -392,6 +392,8 @@ enable_event_scripts() {
b4b3ce
 	local event_dir
b4b3ce
 	event_dir=$OCF_RESKEY_ctdb_config_dir/events.d
b4b3ce
 
b4b3ce
+	chmod u+x "$event_dir/00.ctdb"	# core database health check
b4b3ce
+
b4b3ce
 	if [ -f "${OCF_RESKEY_ctdb_config_dir}/public_addresses" ]; then
b4b3ce
 		chmod u+x "$event_dir/10.interface"
b4b3ce
 	else
b4b3ce
@@ -563,17 +565,6 @@ ctdb_start() {
b4b3ce
 	rv=$?
b4b3ce
 	[ $rv -ne 0 ] && return $rv
b4b3ce
 
b4b3ce
-	# Die if databases are corrupted
b4b3ce
-	persistent_db_dir="${OCF_RESKEY_ctdb_dbdir}/persistent"
b4b3ce
-	mkdir -p $persistent_db_dir 2>/dev/null
b4b3ce
-	for pdbase in $persistent_db_dir/*.tdb.[0-9]; do
b4b3ce
-		[ -f "$pdbase" ] || break
b4b3ce
-		/usr/bin/tdbdump "$pdbase" >/dev/null 2>/dev/null || {
b4b3ce
-			ocf_exit_reason "Persistent database $pdbase is corrupted!  CTDB will not start."
b4b3ce
-			return $OCF_ERR_GENERIC
b4b3ce
-		}
b4b3ce
-	done
b4b3ce
-
b4b3ce
 	# Add necessary configuration to smb.conf
b4b3ce
 	init_smb_conf
b4b3ce
 	if [ $? -ne 0 ]; then
b4b3ce
@@ -737,9 +728,8 @@ ctdb_monitor() {
b4b3ce
 
b4b3ce
 
b4b3ce
 ctdb_validate() {
b4b3ce
-	# Required binaries (full path to tdbdump is intentional, as that's
b4b3ce
-	# what's used in ctdb_start, which was lifted from the init script)
b4b3ce
-	for binary in pkill /usr/bin/tdbdump; do
b4b3ce
+	# Required binaries
b4b3ce
+	for binary in pkill; do
b4b3ce
 		check_binary $binary
b4b3ce
 	done
b4b3ce
 
b4b3ce
b4b3ce
From 1ff4ce7cbe58b5309f00ac1bbe124c562b6dcaf6 Mon Sep 17 00:00:00 2001
b4b3ce
From: David Disseldorp <ddiss@suse.de>
b4b3ce
Date: Fri, 27 Jul 2018 16:02:26 +0200
b4b3ce
Subject: [PATCH 2/3] CTDB: explicitly use bash shell
b4b3ce
b4b3ce
Upcoming recovery lock substring processing is bash specific.
b4b3ce
b4b3ce
Signed-off-by: David Disseldorp <ddiss@suse.de>
b4b3ce
---
b4b3ce
 configure.ac                | 1 +
b4b3ce
 heartbeat/CTDB.in           | 2 +-
b4b3ce
 2 files changed, 2 insertions(+), 1 deletion(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/CTDB.in b/heartbeat/CTDB.in
b4b3ce
index 7d87a4ef7..f9b5c564f 100755
b4b3ce
--- a/heartbeat/CTDB.in
b4b3ce
+++ b/heartbeat/CTDB.in
b4b3ce
@@ -134,8 +134,8 @@ For more information see http://linux-ha.org/wiki/CTDB_(resource_agent)
b4b3ce
 
b4b3ce
 <parameter name="ctdb_recovery_lock" unique="1" required="1">
b4b3ce
 <longdesc lang="en">
b4b3ce
-The location of a shared lock file, common across all nodes.
b4b3ce
-This must be on shared storage, e.g.: /shared-fs/samba/ctdb.lock
b4b3ce
+The location of a shared lock file or helper binary, common across all nodes.
b4b3ce
+See CTDB documentation for details.
b4b3ce
 </longdesc>
b4b3ce
 <shortdesc lang="en">CTDB shared lock file</shortdesc>
b4b3ce
 <content type="string" default="" />
b4b3ce
@@ -757,13 +757,24 @@ ctdb_validate() {
b4b3ce
 		return $OCF_ERR_CONFIGURED
b4b3ce
 	fi
b4b3ce
 
b4b3ce
-	lock_dir=$(dirname "$OCF_RESKEY_ctdb_recovery_lock")
b4b3ce
-	touch "$lock_dir/$$" 2>/dev/null
b4b3ce
-	if [ $? != 0 ]; then
b4b3ce
-		ocf_exit_reason "Directory for lock file '$OCF_RESKEY_ctdb_recovery_lock' does not exist, or is not writable."
b4b3ce
-		return $OCF_ERR_ARGS
b4b3ce
+	if [ "${OCF_RESKEY_ctdb_recovery_lock:0:1}" == '!' ]; then
b4b3ce
+		# '!' prefix means recovery lock is handled via a helper binary
b4b3ce
+		binary="${OCF_RESKEY_ctdb_recovery_lock:1}"
b4b3ce
+		binary="${binary%% *}"	# trim any parameters
b4b3ce
+		if [ -z "$binary" ]; then
b4b3ce
+			ocf_exit_reason "ctdb_recovery_lock invalid helper"
b4b3ce
+			return $OCF_ERR_CONFIGURED
b4b3ce
+		fi
b4b3ce
+		check_binary "${binary}"
b4b3ce
+	else
b4b3ce
+		lock_dir=$(dirname "$OCF_RESKEY_ctdb_recovery_lock")
b4b3ce
+		touch "$lock_dir/$$" 2>/dev/null
b4b3ce
+		if [ $? != 0 ]; then
b4b3ce
+			ocf_exit_reason "Directory for lock file '$OCF_RESKEY_ctdb_recovery_lock' does not exist, or is not writable."
b4b3ce
+			return $OCF_ERR_ARGS
b4b3ce
+		fi
b4b3ce
+		rm "$lock_dir/$$"
b4b3ce
 	fi
b4b3ce
-	rm "$lock_dir/$$"
b4b3ce
 
b4b3ce
 	return $OCF_SUCCESS
b4b3ce
 }