ctdb-daemon: GET_DB_SEQNUM should read database conditionally
authorAmitay Isaacs <amitay@gmail.com>
Thu, 7 Sep 2017 07:21:03 +0000 (17:21 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 12 Sep 2017 10:23:18 +0000 (12:23 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13021

Once the recovery starts and databases are frozen, then all the record
access is postponed till the recovery is complete except reading the
database sequence number.  Database access for reading sequence number
is done via a control which does not check if the databases are frozen
or not.

If the database is frozen and if the freeze transaction is not started
(this can happen when a node is inactive, or during recovery when the
database is frozen but the transaction has not yet started), then trying
to read sequence number will cause ctdb daemon to deadlock.

Before reading the sequence number, check if the database access is
allowed.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/server/ctdb_persistent.c

index 1811ae8fa66a1cbcaf48f26aad26f6a0044a77be..fc2865527474c58119955a9234de810b749cab96 100644 (file)
@@ -344,6 +344,11 @@ static int32_t ctdb_get_db_seqnum(struct ctdb_context *ctdb,
                goto done;
        }
 
+       if (! ctdb_db_allow_access(ctdb_db)) {
+               ret = -1;
+               goto done;
+       }
+
        key.dptr = (uint8_t *)discard_const(keyname);
        key.dsize = strlen(keyname) + 1;