[SCM] CTDB repository - branch master updated - ctdb-1.0.114-159-gf26b59d

Ronnie Sahlberg sahlberg at samba.org
Wed Jun 9 22:33:10 MDT 2010


The branch, master has been updated
       via  f26b59d8b96a70baa80ab1bad406ee6a21330b68 (commit)
       via  069db55ea6fa6b8dd278b880c1a325e259f3e172 (commit)
       via  9eb9c53ef29f4871ae2fe62fc5cb6145fca89eed (commit)
       via  32c04e11ebbcf8239e47016302c6ce802a8b0a6f (commit)
      from  856bd6de6218d9b70baed0e6443be4253ea31afe (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f26b59d8b96a70baa80ab1bad406ee6a21330b68
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Jun 10 14:30:38 2010 +1000

    Wrap the IDR early, but not too early.
    
    We dont want it to wrap almost immediately so that basically all "ctdb ..."
    commands log the "Reqid wrap" warning.

commit 069db55ea6fa6b8dd278b880c1a325e259f3e172
Merge: 856bd6de6218d9b70baed0e6443be4253ea31afe 9eb9c53ef29f4871ae2fe62fc5cb6145fca89eed
Author: Ronnie sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Jun 10 13:33:14 2010 +1000

    Merge commit 'rusty/idtree'

commit 9eb9c53ef29f4871ae2fe62fc5cb6145fca89eed
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Thu Jun 10 08:58:55 2010 +0930

    Delay reusing ids to make protocol more robust
    
    Ronnie and I tracked down a bug which seems to be caused by a node
    running so slowly that we timed out the request and reused the request
    id before it responded.
    
    The result was that we unlocked the wrong record, leading to the
    following:
    
    	ctdbd: tdb_unlock: count is 0
    	ctdbd: tdb_chainunlock failed
    	smbd[1630912]: [2010/06/08 15:32:28.251716,  0] lib/util_sock.c:1491(get_peer_addr_internal)
    	ctdbd: Could not find idr:43
    	ctdbd: server/ctdb_call.c:492 reqid 43 not found
    
    This exact problem is now detected, but in general we want to delay
    id reuse as long as possible to make our system more robust.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 32c04e11ebbcf8239e47016302c6ce802a8b0a6f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Thu Jun 10 08:55:56 2010 +0930

    idtree: fix handling of large ids (eg INT_MAX)
    
    Since idtree assigns sequentially, it rarely reaches high numbers.
    But such numbers can be forced with idr_get_new_above(), and that
    reveals two bugs:
    1) Crash in sub_remove() caused by pa array being too short.
    2) Shift by more than 32 in _idr_find(), which is undefined, causing
       the "outside the current tree" optimization to misfire and return NULL.
    
    Signed-off-by: Rusty Russell <rusty at rustorp.com.au>

-----------------------------------------------------------------------

Summary of changes:
 client/ctdb_client.c   |    2 ++
 common/ctdb_util.c     |    8 +++++++-
 include/ctdb_private.h |    2 +-
 lib/util/idtree.c      |    6 ++++--
 4 files changed, 14 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 05e54a8..01ceb91 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -2916,6 +2916,8 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
 	}
 	ctdb->ev  = ev;
 	ctdb->idr = idr_init(ctdb);
+	/* Wrap early to exercise code. */
+	ctdb->lastid = INT_MAX-200;
 	CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr);
 
 	ret = ctdb_set_socketname(ctdb, CTDB_PATH);
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index f73f8b0..b928c7e 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -159,7 +159,13 @@ void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *l
 
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
 {
-	return idr_get_new(ctdb->idr, state, INT_MAX);
+	int id = idr_get_new_above(ctdb->idr, state, ctdb->lastid+1, INT_MAX);
+	if (id < 0) {
+		DEBUG(DEBUG_NOTICE, ("Reqid wrap!\n"));
+		id = idr_get_new(ctdb->idr, state, INT_MAX);
+	}
+	ctdb->lastid = id;
+	return id;
 }
 
 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location)
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 16e5d60..642a55e 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -412,7 +412,7 @@ struct ctdb_context {
 	unsigned flags;
 	uint32_t capabilities;
 	struct idr_context *idr;
-	uint16_t idr_cnt;
+	int lastid;
 	struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
 	struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
 	struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
diff --git a/lib/util/idtree.c b/lib/util/idtree.c
index 06544e1..ef6d21f 100644
--- a/lib/util/idtree.c
+++ b/lib/util/idtree.c
@@ -240,7 +240,7 @@ build_up:
 static int sub_remove(struct idr_context *idp, int shift, int id)
 {
 	struct idr_layer *p = idp->top;
-	struct idr_layer **pa[MAX_LEVEL];
+	struct idr_layer **pa[1+MAX_LEVEL];
 	struct idr_layer ***paa = &pa[0];
 	int n;
 
@@ -280,8 +280,10 @@ static void *_idr_find(struct idr_context *idp, int id)
 	 * This tests to see if bits outside the current tree are
 	 * present.  If so, tain't one of ours!
 	 */
-	if ((id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDR_BITS))
+	if (n + IDR_BITS < 31 &&
+	    ((id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDR_BITS))) {
 	     return NULL;
+	}
 
 	/* Mask off upper bits we don't use for the search. */
 	id &= MAX_ID_MASK;


-- 
CTDB repository


More information about the samba-cvs mailing list