ctdb-daemon: Fix database attach deferral logic
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Feb 2020 02:48:13 +0000 (13:48 +1100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 30 Mar 2020 10:08:25 +0000 (10:08 +0000)
Commit 3cc230b5eeca749ab68d19cfda969f72c269f1f6 says:

  Dont allow clients to connect to databases untile we are well past
  and through the initial recovery phase

It is unclear what this commit was attempting to do.  The commit
message implies that more attaches should be deferred but the code
change adds a conjunction that causes less attaches to be deferred.
In particular, no attaches will be deferred after startup is complete.
This seems wrong.

To implement what seems to be stated in the commit message an "or"
needs to be used so that non-recovery daemon attaches are deferred
either when in recovery or before startup is complete.  Making this
change highlights that attaches need to be allowed during the
"startup" event because this is when smbd is started.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit c6c89495fbe9b6f238d10a538eccc92b937a69de)

ctdb/server/ctdb_ltdb_server.c

index 970eb54b00b87edfe2ae93c9e0c655a251e4560f..a6709ff72de967854e5b16828568fb630304a975 100644 (file)
@@ -1135,9 +1135,9 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb,
                        return -1;
                }
 
-               if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE &&
-                   client->pid != ctdb->recoverd_pid &&
-                   ctdb->runstate < CTDB_RUNSTATE_RUNNING) {
+               if (client->pid != ctdb->recoverd_pid &&
+                   (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ||
+                    ctdb->runstate < CTDB_RUNSTATE_STARTUP)) {
                        struct ctdb_deferred_attach_context *da_ctx = talloc(client, struct ctdb_deferred_attach_context);
 
                        if (da_ctx == NULL) {