ctdb-recoverd: Handle cancellation when releasing recovery lock
authorMartin Schwenke <martin@meltin.net>
Mon, 3 Sep 2018 03:01:19 +0000 (13:01 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 17 Sep 2018 20:58:20 +0000 (22:58 +0200)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c

index 6a02110153578c7a9331a80e6ed6f0321e90b071..d0eceee62f9f833a194c9804c912d0923f8e7bb4 100644 (file)
@@ -980,6 +980,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);
 }