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

From 6dc93df0ce8ecad540af30535f2d92884cc45d33 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 | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/heartbeat/CTDB b/heartbeat/CTDB
index fcf3f6a7..c171f98b 100755
--- a/heartbeat/CTDB
+++ b/heartbeat/CTDB
@@ -387,6 +387,8 @@ invoke_ctdb() {
 enable_event_scripts() {
 	local 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
@@ -544,16 +546,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 $(ls $persistent_db_dir/*.tdb.[0-9] 2>/dev/null$) ; do
-		/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
@@ -702,9 +694,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

openSUSE Build Service is sponsored by