File 0011-CTDB-fix-incorrect-db-corruption-reports-bsc-1101668.patch of Package resource-agents.8789

From 94e37384b205500509e0595d12ca2830f70ed618 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Wed, 25 Jul 2018 23:15:10 +0200
Subject: [PATCH] CTDB: fix incorrect db corruption reports (bsc#1101668)

If a database was disconnected during an active transaction, then
tdbdump may fail with e.g.:
> /usr/bin/tdbdump /var/lib/ctdb/persistent/secrets.tdb.1
Failed to open /var/lib/ctdb/persistent/secrets.tdb.1
tdb(/var/lib/ctdb/persistent/secrets.tdb.1): FATAL:
tdb_transaction_recover: attempt to recover read only database

This does *not* indicate corruption, only that tdbdump, which opens the
database readonly, isn't able to perform recovery.

Using tdbtool check, instead of tdbdump, passes:
> tdbtool /var/lib/ctdb/persistent/secrets.tdb.1 check
tdb_transaction_recover: recovered 2146304 byte database
Database integrity is OK and has 2 records.

Drop the tdbdump checks, and instead rely on the core ctdb event script,
which performs the same checks with tdbtool.

Signed-off-by: David Disseldorp <ddiss@suse.de>

Cherry-picked from 8c61f201.
---
 heartbeat/CTDB | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/heartbeat/CTDB b/heartbeat/CTDB
index 1456ea32..28e58cea 100755
--- a/heartbeat/CTDB
+++ b/heartbeat/CTDB
@@ -392,6 +392,8 @@ enable_event_scripts() {
 	local event_dir
 	event_dir=$OCF_RESKEY_ctdb_config_dir/events.d
 
+	chmod u+x "$event_dir/00.ctdb"	# core database health check
+
 	if [ -f "${OCF_RESKEY_ctdb_config_dir}/public_addresses" ]; then
 		chmod u+x "$event_dir/10.interface"
 	else
@@ -563,17 +565,6 @@ ctdb_start() {
 	rv=$?
 	[ $rv -ne 0 ] && return $rv
 
-	# Die if databases are corrupted
-	persistent_db_dir="${OCF_RESKEY_ctdb_dbdir}/persistent"
-	mkdir -p $persistent_db_dir 2>/dev/null
-	for pdbase in $persistent_db_dir/*.tdb.[0-9]; do
-		[ -f "$pdbase" ] || break
-		/usr/bin/tdbdump "$pdbase" >/dev/null 2>/dev/null || {
-			ocf_exit_reason "Persistent database $pdbase is corrupted!  CTDB will not start."
-			return $OCF_ERR_GENERIC
-		}
-	done
-
 	# Add necessary configuration to smb.conf
 	init_smb_conf
 	if [ $? -ne 0 ]; then
@@ -737,9 +728,8 @@ ctdb_monitor() {
 
 
 ctdb_validate() {
-	# Required binaries (full path to tdbdump is intentional, as that's
-	# what's used in ctdb_start, which was lifted from the init script)
-	for binary in pkill /usr/bin/tdbdump; do
+	# Required binaries
+	for binary in pkill; do
 		check_binary $binary
 	done
 
-- 
2.13.7