From 21e4884a1a3b25ee5fdf399b3d33bba3af004c99 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 3 Sep 2018 13:01:19 +1000 Subject: ctdb-recoverd: Handle cancellation when releasing recovery lock If the recovery lock is in the process of being taken then free the cluster mutex handle but leave the recovery lock handle in place. This allows ctdb_recovery_lock() to fail. Note that this isn't yet live because rec->recovery_lock_handle is still only set at the completion of the attempt to take the lock. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit b1dc5687844e90b0e3c39cb46a1116c86118fbf4) --- ctdb/server/ctdb_recoverd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ctdb') diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 33df06f2720..5e49e8842d9 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -978,6 +978,20 @@ static void ctdb_recovery_unlock(struct ctdb_recoverd *rec) return; } + if (! rec->recovery_lock_handle->done) { + /* + * Taking of recovery lock still in progress. Free + * the cluster mutex handle to release it but leave + * the recovery lock handle in place to allow taking + * of the lock to fail. + */ + D_NOTICE("Cancelling recovery lock\n"); + TALLOC_FREE(rec->recovery_lock_handle->h); + rec->recovery_lock_handle->done = true; + rec->recovery_lock_handle->locked = false; + return; + } + D_NOTICE("Releasing recovery lock\n"); TALLOC_FREE(rec->recovery_lock_handle); } -- cgit v1.2.1