From 094f34e9bff0ea0499d18a829125b75344bbf65f Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 15 Nov 2013 15:58:59 +1100 Subject: [PATCH] ctdb-locking: Implement active lock requests limit per database This limit was currently a global limit and not per database. This prevents any database freeze lock requests from getting scheduled if the global limit was reached. Only individual record requests should be limited and database freeze requests should always get scheduled. Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam --- ctdb/include/ctdb_private.h | 3 ++- ctdb/server/ctdb_lock.c | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 279fa2f44ad..8135112f62c 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -556,7 +556,6 @@ struct ctdb_context { struct trbt_tree *child_processes; /* Used for locking record/db/alldb */ - int lock_num_current; int lock_num_pending; struct lock_context *lock_current; struct lock_context *lock_pending; @@ -596,6 +595,8 @@ struct ctdb_db_context { struct trbt_tree *deferred_fetch; struct ctdb_db_statistics statistics; + + int lock_num_current; }; diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index bb66f949632..23be5f52e4c 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -279,7 +279,9 @@ static int ctdb_lock_context_destructor(struct lock_context *lock_ctx) if (lock_ctx->child > 0) { ctdb_kill(lock_ctx->ctdb, lock_ctx->child, SIGKILL); DLIST_REMOVE(lock_ctx->ctdb->lock_current, lock_ctx); - lock_ctx->ctdb->lock_num_current--; + if (lock_ctx->ctdb_db) { + lock_ctx->ctdb_db->lock_num_current--; + } CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_current); if (lock_ctx->type == LOCK_RECORD || lock_ctx->type == LOCK_DB) { CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_current); @@ -741,10 +743,6 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb) CTDB_NO_MEMORY_VOID(ctdb, prog); } - if (ctdb->lock_num_current >= MAX_LOCK_PROCESSES_PER_DB) { - return; - } - if (ctdb->lock_pending == NULL) { return; } @@ -767,8 +765,11 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb) lock_ctx->key, lock_ctx->priority, lock_ctx->type); if (active_ctx == NULL) { - /* Found a lock context with lock requests */ - break; + if (lock_ctx->ctdb_db == NULL || + lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) { + /* Found a lock context with lock requests */ + break; + } } /* There is already a child waiting for the @@ -874,7 +875,9 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb) DLIST_REMOVE(ctdb->lock_pending, lock_ctx); ctdb->lock_num_pending--; DLIST_ADD_END(ctdb->lock_current, lock_ctx, NULL); - ctdb->lock_num_current++; + if (lock_ctx->ctdb_db) { + lock_ctx->ctdb_db->lock_num_current++; + } } -- 2.11.4.GIT