|
|
dc8c34 |
From dd322d94a9449915e511b07a5bd0c342e5f72b63 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Rich Megginson <rmeggins@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 25 Jun 2013 19:48:17 -0600
|
|
|
dc8c34 |
Subject: [PATCH 77/99] Ticket #47409 - allow setting db deadlock rejection
|
|
|
dc8c34 |
policy
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47409
|
|
|
dc8c34 |
Reviewed by: nhosoi (Thanks!)
|
|
|
dc8c34 |
Branch: 389-ds-base-1.2.11
|
|
|
dc8c34 |
Fix Description: Add the db config attribute nsslapd-db-deadlock-policy. This
|
|
|
dc8c34 |
takes values from 1-9. The values correspond to the deadlock detector modes
|
|
|
dc8c34 |
in db.h. These are the valid values to pass to the DBENV->lock_detect
|
|
|
dc8c34 |
method for the atype parameter. The default value is 9 (DB_LOCK_YOUNGEST) -
|
|
|
dc8c34 |
select the youngest locker and reject it. A value of 0 (DB_LOCK_NORUN) means
|
|
|
dc8c34 |
to disable deadlock detection and rejection - not recommended except for
|
|
|
dc8c34 |
testing purposes. Attempting to use other values will cause an error.
|
|
|
dc8c34 |
Platforms tested: RHEL6 x86_64
|
|
|
dc8c34 |
Flag Day: no
|
|
|
dc8c34 |
Doc impact: yes - document new config parameter
|
|
|
dc8c34 |
(cherry picked from commit d62cd9b69c8a4a852e7bea0345285dc8c3e1e547)
|
|
|
dc8c34 |
(cherry picked from commit 42a3ef2644d31355da4d82e1f11b2b2eada554a7)
|
|
|
dc8c34 |
(cherry picked from commit f7548908d4749db429f17e23c01624475c121def)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/dblayer.c | 19 +++++++++++-----
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/dblayer.h | 1 +
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/ldbm_config.c | 35 ++++++++++++++++++++++++++++++
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/ldbm_config.h | 2 ++
|
|
|
dc8c34 |
ldap/servers/slapd/slapi-plugin.h | 3 +++
|
|
|
dc8c34 |
5 files changed, 54 insertions(+), 6 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
|
|
|
dc8c34 |
index 2fd2110..85e4a18 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
|
|
|
dc8c34 |
@@ -4206,6 +4206,7 @@ static int deadlock_threadmain(void *param)
|
|
|
dc8c34 |
dblayer_private *priv = NULL;
|
|
|
dc8c34 |
struct ldbminfo *li = NULL;
|
|
|
dc8c34 |
PRIntervalTime interval; /*NSPR timeout stuffy*/
|
|
|
dc8c34 |
+ u_int32_t flags = 0;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
PR_ASSERT(NULL != param);
|
|
|
dc8c34 |
li = (struct ldbminfo*)param;
|
|
|
dc8c34 |
@@ -4220,13 +4221,19 @@ static int deadlock_threadmain(void *param)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
if (priv->dblayer_enable_transactions)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
- if (dblayer_db_uses_locking(priv->dblayer_env->dblayer_DB_ENV)) {
|
|
|
dc8c34 |
- int aborted;
|
|
|
dc8c34 |
- if ((rval = LOCK_DETECT(priv->dblayer_env->dblayer_DB_ENV,
|
|
|
dc8c34 |
- 0, DB_LOCK_YOUNGEST, &aborted)) != 0) {
|
|
|
dc8c34 |
+ DB_ENV *db_env = priv->dblayer_env->dblayer_DB_ENV;
|
|
|
dc8c34 |
+ u_int32_t deadlock_policy = priv->dblayer_deadlock_policy;
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if (dblayer_db_uses_locking(db_env) && (deadlock_policy > DB_LOCK_NORUN)) {
|
|
|
dc8c34 |
+ int rejected = 0;
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if ((rval = LOCK_DETECT(db_env, 0, deadlock_policy, &rejected)) != 0) {
|
|
|
dc8c34 |
LDAPDebug(LDAP_DEBUG_ANY,
|
|
|
dc8c34 |
- "Serious Error---Failed in deadlock detect (aborted at 0x%x), err=%d (%s)\n",
|
|
|
dc8c34 |
- aborted, rval, dblayer_strerror(rval));
|
|
|
dc8c34 |
+ "Serious Error---Failed in deadlock detect (aborted at 0x%x), err=%d (%s)\n",
|
|
|
dc8c34 |
+ rejected, rval, dblayer_strerror(rval));
|
|
|
dc8c34 |
+ } else if (rejected) {
|
|
|
dc8c34 |
+ LDAPDebug1Arg(LDAP_DEBUG_TRACE, "deadlock_threadmain: found and rejected %d lock requests\n", rejected);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.h b/ldap/servers/slapd/back-ldbm/dblayer.h
|
|
|
dc8c34 |
index ab9a85d..7f3200c 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/dblayer.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/dblayer.h
|
|
|
dc8c34 |
@@ -178,6 +178,7 @@ struct dblayer_private
|
|
|
dc8c34 |
PRCondVar *thread_count_cv; /* condition variable for housekeeping thread shutdown */
|
|
|
dc8c34 |
int dblayer_lockdown; /* use DB_LOCKDOWN */
|
|
|
dc8c34 |
int dblayer_lock_config;
|
|
|
dc8c34 |
+ u_int32_t dblayer_deadlock_policy; /* i.e. the atype to DB_ENV->lock_detect in deadlock_threadmain */
|
|
|
dc8c34 |
};
|
|
|
dc8c34 |
|
|
|
dc8c34 |
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
|
|
|
dc8c34 |
index eeae22b..44ccf78 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
|
|
|
dc8c34 |
@@ -1326,6 +1326,40 @@ static int ldbm_config_db_tx_max_set(
|
|
|
dc8c34 |
return retval;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+static void *ldbm_config_db_deadlock_policy_get(void *arg)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ struct ldbminfo *li = (struct ldbminfo *) arg;
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_deadlock_policy);
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+static int ldbm_config_db_deadlock_policy_set(void *arg, void *value, char *errorbuf, int phase, int apply)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ struct ldbminfo *li = (struct ldbminfo *) arg;
|
|
|
dc8c34 |
+ int retval = LDAP_SUCCESS;
|
|
|
dc8c34 |
+ u_int32_t val = (u_int32_t) ((uintptr_t)value);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if ((val < DB_LOCK_NORUN) || (val > DB_LOCK_YOUNGEST)) {
|
|
|
dc8c34 |
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
|
|
|
dc8c34 |
+ "Error: Invalid value for %s (%d). Must be between %d and %d inclusive",
|
|
|
dc8c34 |
+ CONFIG_DB_DEADLOCK_POLICY, val, DB_LOCK_DEFAULT, DB_LOCK_YOUNGEST);
|
|
|
dc8c34 |
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s\n", errorbuf);
|
|
|
dc8c34 |
+ return LDAP_UNWILLING_TO_PERFORM;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if (val == DB_LOCK_NORUN) {
|
|
|
dc8c34 |
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
|
|
|
dc8c34 |
+ "Warning: Setting value for %s to (%d) will disable deadlock detection",
|
|
|
dc8c34 |
+ CONFIG_DB_DEADLOCK_POLICY, val);
|
|
|
dc8c34 |
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s\n", errorbuf);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if (apply) {
|
|
|
dc8c34 |
+ li->li_dblayer_private->dblayer_deadlock_policy = val;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ return retval;
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/*------------------------------------------------------------------------
|
|
|
dc8c34 |
* Configuration array for ldbm and dblayer variables
|
|
|
dc8c34 |
@@ -1385,6 +1419,7 @@ static config_info ldbm_config[] = {
|
|
|
dc8c34 |
{CONFIG_PAGEDLOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedlookthroughlimit_get, &ldbm_config_pagedlookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
|
|
|
dc8c34 |
{CONFIG_PAGEDIDLISTSCANLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedallidsthreshold_get, &ldbm_config_pagedallidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
|
|
|
dc8c34 |
{CONFIG_RANGELOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_rangelookthroughlimit_get, &ldbm_config_rangelookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
|
|
|
dc8c34 |
+ {CONFIG_DB_DEADLOCK_POLICY, CONFIG_TYPE_INT, STRINGIFYDEFINE(DB_LOCK_YOUNGEST), &ldbm_config_db_deadlock_policy_get, &ldbm_config_db_deadlock_policy_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
|
|
|
dc8c34 |
{NULL, 0, NULL, NULL, NULL, 0}
|
|
|
dc8c34 |
};
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
|
|
|
dc8c34 |
index 33eb078..553d387 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
|
|
|
dc8c34 |
@@ -159,6 +159,8 @@ struct config_info {
|
|
|
dc8c34 |
|
|
|
dc8c34 |
#define CONFIG_USE_LEGACY_ERRORCODE "nsslapd-do-not-use-vlv-error"
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+#define CONFIG_DB_DEADLOCK_POLICY "nsslapd-db-deadlock-policy"
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
#define CONFIG_LDBM_DN "cn=config,cn=ldbm database,cn=plugins,cn=config"
|
|
|
dc8c34 |
|
|
|
dc8c34 |
#define LDBM_INSTANCE_CONFIG_DONT_WRITE 1
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
index 0f69c0a..5b3e1ab 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
@@ -107,6 +107,9 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
|
|
|
dc8c34 |
#define BERLEN_T "u"
|
|
|
dc8c34 |
#endif
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+#define DEFINETOSTR(xxx) #xxx
|
|
|
dc8c34 |
+#define STRINGIFYDEFINE(xxx) DEFINETOSTR(xxx)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
/* Common check on berval before accessing the contents. */
|
|
|
dc8c34 |
/* bv is a struct berval *bv */
|
|
|
dc8c34 |
#define BV_HAS_DATA(bv) ((bv != NULL) && (bv->bv_len > 0) && (bv->bv_val != NULL))
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|