[SCM] CTDB repository - branch master updated - ctdb-1.11-85-g0a2ea7e
Ronnie Sahlberg
sahlberg at samba.org
Sun Oct 23 20:30:51 MDT 2011
The branch, master has been updated
via 0a2ea7e1a1e034a9a17debff763084a0936b0515 (commit)
via b44ded0e0771c87321b568588c08195222a026c3 (commit)
via bf1d429227dc4f5818263cc39401d0a22663cdba (commit)
via db0fdc2281c4742113c92d697371c37815db35a0 (commit)
from 99de5bceb788ba56ebc052c05d29a834ba2496fa (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0a2ea7e1a1e034a9a17debff763084a0936b0515
Merge: 99de5bceb788ba56ebc052c05d29a834ba2496fa b44ded0e0771c87321b568588c08195222a026c3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon Oct 24 13:30:28 2011 +1100
Merge branch 'master' of 10.1.1.27:/shared/ctdb/ctdb-master
commit b44ded0e0771c87321b568588c08195222a026c3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon Oct 24 13:19:30 2011 +1100
ReadOnly DOCS: update the docs for readonly delegations to remove the passage that records are written/updated by the client
commit bf1d429227dc4f5818263cc39401d0a22663cdba
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon Oct 24 13:14:26 2011 +1100
ReadOnly: Dont update the record header from the calling client. While it is convenient since it avoids having to create a child process from the main dameon for writing the updated record it makes the cleitn more complex.
Remove the code in the example client code that writes the record to the local tdb.
Add code to the local ctdbd processing of replies to check if this reply contain a ro delegation and if so, spawn a child process to lock the tdb and then write the data.
commit db0fdc2281c4742113c92d697371c37815db35a0
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon Oct 24 12:21:55 2011 +1100
Remove debug message
-----------------------------------------------------------------------
Summary of changes:
client/ctdb_client.c | 26 ---------------------
doc/readonlyrecords.txt | 7 -----
server/ctdb_call.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
server/ctdb_ltdb_server.c | 2 -
4 files changed, 54 insertions(+), 35 deletions(-)
Changeset truncated at 500 lines:
diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index f2359ca..f0172e4 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -843,32 +843,6 @@ again:
goto again;
}
- if (h->header.rsn >= roheader->rsn) {
- DEBUG(DEBUG_ERR,("READONLY RECORD: Too small RSN, migrate and try again\n"));
- ctdb_ltdb_unlock(ctdb_db, key);
-
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
-
- goto again;
- }
-
- if (ctdb_ltdb_store(ctdb_db, key, roheader, rodata) != 0) {
- ctdb_ltdb_unlock(ctdb_db, key);
-
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
-
- goto again;
- }
return h;
}
diff --git a/doc/readonlyrecords.txt b/doc/readonlyrecords.txt
index c07d583..acdab2e 100644
--- a/doc/readonlyrecords.txt
+++ b/doc/readonlyrecords.txt
@@ -142,11 +142,6 @@ This will change to instead do
ask ctdb to migrate the record onto the node
goto try_again
lock record in tdb
- if record fails RSN test
- unlock record
- ask ctdb to migrate the record onto the node
- goto try_again
- write the updated record from ctdb to tdb
goto finished
unlock record
@@ -168,8 +163,6 @@ This heuristics provide a mechanism where we will not create Read-Only delegatio
This avoids creating and revoking Read-Only delegations when only a single client is repeatedly accessing the same set of records.
This also aims to limit the size of the tracking tdb.
-Note that writing the copy of the Read-Only record to the TDB database is done by the client, not by ctdbd. This is to avoid a probable need for creating a child process for a likely contended record where locking the record would likely block.
-
Server implementation
=====================
diff --git a/server/ctdb_call.c b/server/ctdb_call.c
index 9e86422..9fc8b33 100644
--- a/server/ctdb_call.c
+++ b/server/ctdb_call.c
@@ -700,6 +700,60 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
return;
}
+
+ /* read only delegation processing */
+ /* If we got a FETCH_WITH_HEADER we should check if this is a ro
+ * delegation since we may need to update the record header
+ */
+ if (state->c->callid == CTDB_FETCH_WITH_HEADER_FUNC) {
+ struct ctdb_db_context *ctdb_db = state->ctdb_db;
+ struct ctdb_ltdb_header *header = (struct ctdb_ltdb_header *)&c->data[0];
+ struct ctdb_ltdb_header oldheader;
+ TDB_DATA key, data, olddata;
+ int ret;
+
+ if (!(header->flags & CTDB_REC_RO_HAVE_READONLY)) {
+ goto finished_ro;
+ return;
+ }
+
+ key.dsize = state->c->keylen;
+ key.dptr = state->c->data;
+ ret = ctdb_ltdb_lock_requeue(ctdb_db, key, hdr,
+ ctdb_call_input_pkt, ctdb, False);
+ if (ret == -2) {
+ return;
+ }
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " Failed to get lock in ctdb_reply_call\n"));
+ return;
+ }
+
+ ret = ctdb_ltdb_fetch(ctdb_db, key, &oldheader, state, &olddata);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Failed to fetch old record in ctdb_reply_call\n"));
+ ctdb_ltdb_unlock(ctdb_db, key);
+ goto finished_ro;
+ }
+
+ if (header->rsn <= oldheader.rsn) {
+ ctdb_ltdb_unlock(ctdb_db, key);
+ goto finished_ro;
+ }
+
+ data.dptr = &c->data[sizeof(struct ctdb_ltdb_header)];
+ data.dsize = sizeof(struct ctdb_ltdb_header);
+ ret = ctdb_ltdb_store(ctdb_db, key, header, data);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Failed to store new record in ctdb_reply_call\n"));
+ ctdb_ltdb_unlock(ctdb_db, key);
+ goto finished_ro;
+ }
+
+ ctdb_ltdb_unlock(ctdb_db, key);
+ }
+finished_ro:
+
state->call->reply_data.dptr = c->data;
state->call->reply_data.dsize = c->datalen;
state->call->status = c->status;
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index b76ae6a..745b3d2 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -728,8 +728,6 @@ int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb
{
char *ropath;
- DEBUG(DEBUG_ERR,("XXX set db readonly %s\n", ctdb_db->db_name));
-
if (ctdb_db->readonly) {
return 0;
}
--
CTDB repository
More information about the samba-cvs
mailing list