[PATCH] ctdb-locking: Back-off from logging every 10 seconds

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Mar 5 03:31:24 MST 2015


On Thu, Mar 05, 2015 at 04:27:35PM +1100, Amitay Isaacs wrote:
> This patch prevents flooding of debug logs by locking code when a lock
> helper is unable to obtain a lock for a long time.  Instead of logging
> every 10 seconds, increase the interval to 100 seconds and 1000 seconds
> when the elapsed time reaches 100 seconds and 1000 seconds respectively.
> 
> Please review and push if ok.

Pushed, thanks! I wonder if we can somehow generalize this
pattern...

Attached find two small patches on top of your patch.

Review&push if ok.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 399f0fd49b059deb365df239e515869231cb0dd1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 5 Mar 2015 11:26:12 +0100
Subject: [PATCH 1/2] ctdb: Remove a //-style comment

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/server/ctdb_lock.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index c5a2b98..8d28619 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -542,7 +542,6 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 	}
 
 	/* reset the timeout timer */
-	// talloc_free(lock_ctx->ttimer);
 	lock_ctx->ttimer = tevent_add_timer(ctdb->ev,
 					    lock_ctx,
 					    timeval_current_ofs(new_timer, 0),
-- 
1.9.1


From 991426b0463061d91baee47f186bc3a071f0df3d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 5 Mar 2015 11:29:21 +0100
Subject: [PATCH 2/2] ctdb: Fix a memleak

"ctdb" is a long-running context. Don't leak strings there.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/server/ctdb_lock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index 8d28619..62d3e4f 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -483,6 +483,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 				    void *private_data)
 {
 	static const char * debug_locks = NULL;
+	char *to_free = NULL;
 	struct lock_context *lock_ctx;
 	struct ctdb_context *ctdb;
 	pid_t pid;
@@ -514,9 +515,10 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 	if (debug_locks == NULL) {
 		debug_locks = getenv("CTDB_DEBUG_LOCKS");
 		if (debug_locks == NULL) {
-			debug_locks = talloc_asprintf(ctdb,
+			to_free = talloc_asprintf(ctdb,
 						      "%s/debug_locks.sh",
 						      getenv("CTDB_BASE"));
+			debug_locks = to_free;
 		}
 	}
 	if (debug_locks != NULL) {
@@ -526,6 +528,8 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 			_exit(0);
 		}
 		ctdb_track_child(ctdb, pid);
+		TALLOC_FREE(to_free);
+		debug_locks = NULL;
 	} else {
 		DEBUG(DEBUG_WARNING,
 		      (__location__
-- 
1.9.1



More information about the samba-technical mailing list