summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-04-02 17:17:47 +1100
committerDavid Disseldorp <ddiss@samba.org>2014-04-07 14:06:26 +0200
commit01de7818def1367fd55d8fbd80432c5a02c3e1f6 (patch)
tree09f411dc5e268177429b59eda594a41b3090f423
parent5963519ec33c436ae4616c556d8ab5c6028e6bf6 (diff)
downloadsamba-01de7818def1367fd55d8fbd80432c5a02c3e1f6.tar.gz
samba-01de7818def1367fd55d8fbd80432c5a02c3e1f6.tar.xz
samba-01de7818def1367fd55d8fbd80432c5a02c3e1f6.zip
ctdb-daemon: Always update database priority cluster wide
Database priority is a global property and all the nodes should have the priority set for the databases. Just setting priority on one node can lead to problems in the recovery as a database can be frozen at wrong priority and then freezing database would not succeed. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Mon Apr 7 14:06:26 CEST 2014 on sn-devel-104
-rw-r--r--ctdb/include/ctdb_private.h3
-rw-r--r--ctdb/server/ctdb_control.c2
-rw-r--r--ctdb/server/ctdb_ltdb_server.c10
-rw-r--r--ctdb/server/ctdb_recoverd.c19
4 files changed, 17 insertions, 17 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 8ed867d5101..2206f4edfd9 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -1440,7 +1440,8 @@ int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
void ctdb_local_node_got_banned(struct ctdb_context *ctdb);
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
-int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata,
+ uint32_t client_id);
void ctdb_ban_self(struct ctdb_context *ctdb);
int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index b407a1ff7ae..b56b624f00c 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -603,7 +603,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
case CTDB_CONTROL_SET_DB_PRIORITY:
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_db_priority));
- return ctdb_control_set_db_priority(ctdb, indata);
+ return ctdb_control_set_db_priority(ctdb, indata, client_id);
case CTDB_CONTROL_GET_DB_PRIORITY: {
uint32_t db_id;
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 234ecac5fcd..aafba42c564 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -1425,7 +1425,8 @@ int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id)
return 0;
}
-int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata)
+int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata,
+ uint32_t client_id)
{
struct ctdb_db_priority *db_prio = (struct ctdb_db_priority *)indata.dptr;
struct ctdb_db_context *ctdb_db;
@@ -1444,6 +1445,13 @@ int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata)
ctdb_db->priority = db_prio->priority;
DEBUG(DEBUG_INFO,("Setting DB priority to %u for db 0x%08x\n", db_prio->priority, db_prio->db_id));
+ if (client_id != 0) {
+ /* Broadcast the update to the rest of the cluster */
+ ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
+ CTDB_CONTROL_SET_DB_PRIORITY, 0,
+ CTDB_CTRL_FLAG_NOREPLY, indata,
+ NULL, NULL);
+ }
return 0;
}
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 179eb7d311b..ac692ec5419 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -458,13 +458,9 @@ static int update_db_priority_on_remote_nodes(struct ctdb_context *ctdb,
uint32_t pnn, struct ctdb_dbid_map *dbmap, TALLOC_CTX *mem_ctx)
{
int db;
- uint32_t *nodes;
-
- nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
/* step through all local databases */
for (db=0; db<dbmap->num;db++) {
- TDB_DATA data;
struct ctdb_db_priority db_prio;
int ret;
@@ -477,16 +473,11 @@ static int update_db_priority_on_remote_nodes(struct ctdb_context *ctdb,
DEBUG(DEBUG_INFO,("Update DB priority for db 0x%08x to %u\n", dbmap->dbs[db].dbid, db_prio.priority));
- data.dptr = (uint8_t *)&db_prio;
- data.dsize = sizeof(db_prio);
-
- if (ctdb_client_async_control(ctdb,
- CTDB_CONTROL_SET_DB_PRIORITY,
- nodes, 0,
- CONTROL_TIMEOUT(), false, data,
- NULL, NULL,
- NULL) != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to set DB priority for 0x%08x\n", db_prio.db_id));
+ ret = ctdb_ctrl_set_db_priority(ctdb, CONTROL_TIMEOUT(),
+ CTDB_CURRENT_NODE, &db_prio);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " Failed to set DB priority for 0x%08x\n",
+ db_prio.db_id));
}
}