Blame SOURCES/bz1719443-CTDB-1-fixes.patch

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