diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-07-17 13:50:55 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-07-17 13:50:55 +1000 |
commit | 6eb4e46fe1f2b14178bbd21930f7bca486a1ed2e (patch) | |
tree | 8650d21b514d2345b3bbab505fc268c0f9fdd0a2 /ctdb/server/ctdb_persistent.c | |
parent | 0964c59dc6706311fd565d91289e922be5e3a864 (diff) | |
download | samba-6eb4e46fe1f2b14178bbd21930f7bca486a1ed2e.tar.gz samba-6eb4e46fe1f2b14178bbd21930f7bca486a1ed2e.tar.xz samba-6eb4e46fe1f2b14178bbd21930f7bca486a1ed2e.zip |
Add two new controls to start and cancel a persistent update.
This allows ctdb to automatically start a new full blown recovery
if a client has started updating the local tdb for a persistent database
but is kill -9ed before it has ensured the update is distributed clusterwide.
(This used to be ctdb commit 1ffccb3e0b3b5bd376c5302304029af393709518)
Diffstat (limited to 'ctdb/server/ctdb_persistent.c')
-rw-r--r-- | ctdb/server/ctdb_persistent.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_persistent.c b/ctdb/server/ctdb_persistent.c index 713950a0c9..66311a9f89 100644 --- a/ctdb/server/ctdb_persistent.c +++ b/ctdb/server/ctdb_persistent.c @@ -81,9 +81,16 @@ int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA recdata, bool *async_reply) { + struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client); struct ctdb_persistent_state *state; int i; + if (client == NULL) { + DEBUG(DEBUG_ERR,(__location__ " can not match persistent_store to a client. Returning error\n")); + return -1; + } + client->num_persistent_updates--; + state = talloc_zero(ctdb, struct ctdb_persistent_state); CTDB_NO_MEMORY(ctdb, state); @@ -410,3 +417,44 @@ int32_t ctdb_control_update_record(struct ctdb_context *ctdb, return 0; } + + + +/* + start a persistent store operation. passing both the key, header and + data to the daemon. If the client disconnects before it has issued + a persistent_update call to the daemon we trigger a full recovery + to ensure the databases are brought back in sync. + for now we ignore the recdata that the client has passed to us. + */ +int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb, + struct ctdb_req_control *c, + TDB_DATA recdata) +{ + struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client); + + if (client == NULL) { + DEBUG(DEBUG_ERR,(__location__ " can not match start_persistent_update to a client. Returning error\n")); + return -1; + } + + client->num_persistent_updates++; + + return 0; +} + +int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb, + struct ctdb_req_control *c, + TDB_DATA recdata) +{ + struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client); + + if (client == NULL) { + DEBUG(DEBUG_ERR,(__location__ " can not match cancel_persistent_update to a client. Returning error\n")); + return -1; + } + + client->num_persistent_updates--; + + return 0; +} |