1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

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
This commit is contained in:
Amitay Isaacs 2014-04-02 17:17:47 +11:00 committed by David Disseldorp
parent 5963519ec3
commit 01de7818de
4 changed files with 17 additions and 17 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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));
}
}