recoverd: Use correct tdb flags when creating missing databases
authorAmitay Isaacs <amitay@gmail.com>
Tue, 30 Jul 2013 02:45:01 +0000 (12:45 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 1 Aug 2013 01:08:25 +0000 (11:08 +1000)
When creating missing databases either locally or remotely, make sure
to use the correct tdb flags from other nodes.  Without this, volatile
databases can get attached without TDB_INCOMPATIBLE_HASH flag.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 10a057d8e15c8c18e540598a940d3548c731b0b4)

ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h
ctdb/server/ctdb_recoverd.c

index e801c0138eebdb91e2ab684f6719706a3d77b50c..ebd448ccbfda0b4ac970a86b487177ce56e1d868 100644 (file)
@@ -1781,19 +1781,21 @@ int ctdb_ctrl_getdbhealth(struct ctdb_context *ctdb,
 /*
   create a database
  */
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, 
-                      TALLOC_CTX *mem_ctx, const char *name, bool persistent)
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
+                      TALLOC_CTX *mem_ctx, const char *name, uint32_t tdb_flags)
 {
        int ret;
        int32_t res;
        TDB_DATA data;
+       bool persistent;
 
        data.dptr = discard_const(name);
        data.dsize = strlen(name)+1;
 
-       ret = ctdb_control(ctdb, destnode, 0, 
-                          persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH, 
-                          0, data, 
+       persistent = (tdb_flags & CTDB_DB_FLAGS_PERSISTENT);
+       ret = ctdb_control(ctdb, destnode, 0,
+                          persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
+                          tdb_flags, data,
                           mem_ctx, &data, &res, &timeout, NULL);
 
        if (ret != 0 || res != 0) {
index 873992370130f74cbec4830094474bfd66b0cd3f..b2ae3bf8caa0b4e86fc95a588b9a28ef67c64441 100644 (file)
@@ -289,7 +289,7 @@ int ctdb_ctrl_getdbhealth(struct ctdb_context *ctdb,
                          uint32_t destnode,
                          uint32_t dbid, TALLOC_CTX *mem_ctx,
                          const char **reason);
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, uint32_t tdb_flags);
 
 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
 
index a1513ee278d93624cd622f407f6ee3b59928ee66..cb07339ca3fb933178b25541e815bb5d75633b9d 100644 (file)
@@ -468,7 +468,7 @@ static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctd
                        }
                        ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, 
                                           mem_ctx, name,
-                                          dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
+                                          dbmap->dbs[db].flags);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
                                return -1;
@@ -531,7 +531,7 @@ static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb
                                return -1;
                        }
                        ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, name, 
-                                          remote_dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
+                                          remote_dbmap->dbs[db].flags);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));
                                return -1;