[SCM] CTDB repository - branch master updated - ctdb-1.0.101-8-g467da12

Ronnie Sahlberg sahlberg at samba.org
Wed Oct 28 17:50:35 MDT 2009


The branch, master has been updated
       via  467da12a785ba3367ed9cbdf79440394e9703289 (commit)
       via  cb36bbb5418290e8e5b770d2d836285b15da2a6f (commit)
      from  22712c577f64ec84851b4addcf4a46c7e99e0662 (commit)

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


- Log -----------------------------------------------------------------
commit 467da12a785ba3367ed9cbdf79440394e9703289
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Oct 29 10:58:14 2009 +1100

    update the uptime command to indicate that time since last is either from alst recovery or from last failover

commit cb36bbb5418290e8e5b770d2d836285b15da2a6f
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Oct 29 10:49:00 2009 +1100

    Revert "update the "uptime" command to indicate the "time since last" is the time since the last recovery OR failover."
    
    This reverts commit 3b0d44497800a16400d05a30bdaf6e6c285d4b36.

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

Summary of changes:
 client/ctdb_client.c         |   48 +++++++++++++++++++++++++++++++++++++++--
 config/events.d/61.nfstickle |    2 +-
 include/ctdb_private.h       |    3 ++
 server/ctdb_control.c        |    4 +++
 server/ctdb_persistent.c     |   20 +++++++++++++++++
 5 files changed, 73 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index d4130cd..d47f771 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -3141,12 +3141,42 @@ int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout,
 	return ret;
 }
 
+/**
+ * check whether a transaction is active on a given db on a given node
+ */
+static int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
+					    uint32_t destnode,
+					    uint32_t db_id)
+{
+	int32_t status;
+	int ret;
+	TDB_DATA indata;
+
+	indata.dptr = (uint8_t *)&db_id;
+	indata.dsize = sizeof(db_id);
+
+	ret = ctdb_control(ctdb, destnode, 0,
+			   CTDB_CONTROL_TRANS2_ACTIVE,
+			   0, indata, NULL, NULL, &status,
+			   NULL, NULL);
+
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, (__location__ " ctdb control for transaction_active failed\n"));
+		return -1;
+	}
+
+	return status;
+}
+
+
 struct ctdb_transaction_handle {
 	struct ctdb_db_context *ctdb_db;
 	bool in_replay;
-	/* we store the reads and writes done under a transaction one
-	   list stores both reads and writes, the other just writes
-	*/
+	/*
+	 * we store the reads and writes done under a transaction:
+	 * - one list stores both reads and writes (m_all),
+	 * - the other just writes (m_write)
+	 */
 	struct ctdb_marshall_buffer *m_all;
 	struct ctdb_marshall_buffer *m_write;
 };
@@ -3170,6 +3200,7 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
 	int ret;
 	struct ctdb_db_context *ctdb_db = h->ctdb_db;
 	pid_t pid;
+	int32_t status;
 
 	key.dptr = discard_const(keyname);
 	key.dsize = strlen(keyname);
@@ -3180,6 +3211,17 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
 	}
 
 again:
+	status = ctdb_ctrl_transaction_active(ctdb_db->ctdb,
+					      CTDB_CURRENT_NODE,
+					      ctdb_db->db_id);
+	if (status == 1) {
+		DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
+				     "on db_id[%u]. waiting for 1 second\n",
+				     ctdb_db->db_id));
+		sleep(1);
+		goto again;
+	}
+
 	tmp_ctx = talloc_new(h);
 
 	rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
diff --git a/config/events.d/61.nfstickle b/config/events.d/61.nfstickle
index 3e557e4..332d006 100755
--- a/config/events.d/61.nfstickle
+++ b/config/events.d/61.nfstickle
@@ -56,7 +56,7 @@ case $cmd in
 	;;
 
      monitor)
-# always create these direcotries since NFS might be enabled at runtime
+        # always create these direcotries since NFS might be enabled at runtime
 	# and we dont want to restart ctdbd
 	mkdir -p $CTDB_BASE/state/nfstickle
 	mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 5791df0..2fabfea 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -620,6 +620,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
 		    CTDB_CONTROL_REGISTER_NOTIFY         = 114,
 		    CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
+		    CTDB_CONTROL_TRANS2_ACTIVE           = 116,
 };	
 
 /*
@@ -1469,6 +1470,8 @@ int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb,
 				     struct ctdb_req_control *c);
 int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb, 
 				  struct ctdb_req_control *c);
+int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
+				   uint32_t db_id);
 
 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
 unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 7e84078..b6bad1c 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -424,6 +424,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 	case CTDB_CONTROL_TRANS2_FINISHED:
 		return ctdb_control_trans2_finished(ctdb, c);
 
+	case CTDB_CONTROL_TRANS2_ACTIVE:
+		CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
+		return ctdb_control_trans2_active(ctdb, *(uint32_t *)indata.dptr);
+
 	case CTDB_CONTROL_RECD_PING:
 		CHECK_CONTROL_DATA_SIZE(0);
 		return ctdb_control_recd_ping(ctdb);
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index cb77bf0..3c51742 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -604,6 +604,26 @@ int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
 	return 0;
 }
 
+/**
+ * Tell whether a transaction is active on this node on the give DB.
+ */
+int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
+				   uint32_t db_id)
+{
+	struct ctdb_db_context *ctdb_db;
+
+	ctdb_db = find_ctdb_db(ctdb, db_id);
+	if (!ctdb_db) {
+		DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", db_id));
+		return -1;
+	}
+
+	if (ctdb_db->transaction_active) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
 
 /*
   backwards compatibility:


-- 
CTDB repository


More information about the samba-cvs mailing list