summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_persistent.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-02-23 17:35:27 +0100
committerMichael Adam <obnox@samba.org>2011-02-24 10:35:25 +0100
commit0b3d8d28f6610b59fd7153a50325dfc9d7d9123c (patch)
tree4c26a5a04584d49a903b04b8b386f77ff5e164cc /ctdb/server/ctdb_persistent.c
parent65f7a449873dec21e2fa8af5d51a57c3a1c013a4 (diff)
downloadsamba-0b3d8d28f6610b59fd7153a50325dfc9d7d9123c.tar.gz
samba-0b3d8d28f6610b59fd7153a50325dfc9d7d9123c.tar.xz
samba-0b3d8d28f6610b59fd7153a50325dfc9d7d9123c.zip
persistent: add a client context to the persistent_stat and track the db_id
The db_id is tracked in the client context as an indication that a transaction commit is in progress. This is cleared in the persistent_state talloc destructor. This is in order to properly treat running trans3_commits if the client disconnects. (This used to be ctdb commit e886ff24f4e3e250944289db95916b948893d26c)
Diffstat (limited to 'ctdb/server/ctdb_persistent.c')
-rw-r--r--ctdb/server/ctdb_persistent.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/ctdb/server/ctdb_persistent.c b/ctdb/server/ctdb_persistent.c
index c7a53ca066..0627037ea9 100644
--- a/ctdb/server/ctdb_persistent.c
+++ b/ctdb/server/ctdb_persistent.c
@@ -29,6 +29,7 @@
struct ctdb_persistent_state {
struct ctdb_context *ctdb;
struct ctdb_db_context *ctdb_db; /* used by trans3_commit */
+ struct ctdb_client *client; /* used by trans3_commit */
struct ctdb_req_control *c;
const char *errormsg;
uint32_t num_pending;
@@ -277,6 +278,10 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
static int ctdb_persistent_state_destructor(struct ctdb_persistent_state *state)
{
+ if (state->client != NULL) {
+ state->client->db_id = 0;
+ }
+
if (state->ctdb_db != NULL) {
state->ctdb_db->persistent_state = NULL;
}
@@ -303,6 +308,21 @@ int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
return -1;
}
+ client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
+ if (client == NULL) {
+ DEBUG(DEBUG_ERR,(__location__ " can not match persistent_store "
+ "to a client. Returning error\n"));
+ return -1;
+ }
+
+ if (client->db_id != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ERROR: trans3_commit: "
+ "client-db_id[0x%08x] != 0 "
+ "(client_id[0x%08x]): trans3_commit active?\n",
+ client->db_id, client->client_id));
+ return -1;
+ }
+
ctdb_db = find_ctdb_db(ctdb, m->db_id);
if (ctdb_db == NULL) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control_trans3_commit: "
@@ -318,21 +338,18 @@ int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
return -1;
}
- client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
- if (client == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " can not match persistent_store "
- "to a client. Returning error\n"));
- return -1;
- }
-
ctdb_db->persistent_state = talloc_zero(ctdb_db,
struct ctdb_persistent_state);
CTDB_NO_MEMORY(ctdb, ctdb_db->persistent_state);
+ client->db_id = m->db_id;
+
state = ctdb_db->persistent_state;
state->ctdb = ctdb;
state->ctdb_db = ctdb_db;
state->c = c;
+ state->client = client;
+
talloc_set_destructor(state, ctdb_persistent_state_destructor);
for (i = 0; i < ctdb->vnn_map->size; i++) {