ctdb_freeze: extend db priority hack to cover serverid.tdb deadlock.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 1 Jul 2010 11:46:55 +0000 (21:46 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 1 Jul 2010 13:09:59 +0000 (23:09 +1000)
We discovered that recent smbd locks the serverid tdb while
holding a lock on another tdb (locking.tdb):
  7: POSIX  ADVISORY  WRITE smbd-2224318 locking.tdb.0 10600 10600
  22: -> POSIX  ADVISORY  READ  smbd-2224318 serverid.tdb.0 26580 26580

The result is a deadlock against the ctdb_freeze code called for
recovery.  We extend the "notify" workaround to this case, too.

BZ:65158
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
server/ctdb_freeze.c

index 70333b0b33ddf11f6e6afdf56f792686e58f8b82..e641ef3ae68c5e756250416441630e8b153b1b6d 100644 (file)
 #include "lib/util/dlinklist.h"
 #include "db_wrap.h"
 
+static bool later_db(const char *name)
+{
+       return (strstr(name, "notify") || strstr(name, "serverid"));
+}
 
 /*
   lock all databases
@@ -43,7 +47,7 @@ static int ctdb_lock_all_databases(struct ctdb_context *ctdb, uint32_t priority)
                if (ctdb_db->priority != priority) {
                        continue;
                }
-               if (strstr(ctdb_db->db_name, "notify") != NULL) {
+               if (later_db(ctdb_db->db_name)) {
                        continue;
                }
                DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
@@ -56,7 +60,7 @@ static int ctdb_lock_all_databases(struct ctdb_context *ctdb, uint32_t priority)
                if (ctdb_db->priority != priority) {
                        continue;
                }
-               if (strstr(ctdb_db->db_name, "notify") == NULL) {
+               if (!later_db(ctdb_db->db_name)) {
                        continue;
                }
                DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));