|
|
74ca47 |
From 0f04c8e7c1219940baf0ae9c1bcb2464ddf079df Mon Sep 17 00:00:00 2001
|
|
|
74ca47 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
74ca47 |
Date: Tue, 16 May 2017 13:19:43 -0400
|
|
|
74ca47 |
Subject: [PATCH] Ticket 49257 - Reject nsslapd-cachememsize &
|
|
|
74ca47 |
nsslapd-cachesize when nsslapd-cache-autosize is set
|
|
|
74ca47 |
|
|
|
74ca47 |
Description: We need to also reject entry cache changes when cache autosizing is being used.
|
|
|
74ca47 |
|
|
|
74ca47 |
I also found out that we were not registering the ldbm instance callbacks at startup.
|
|
|
74ca47 |
So all those functions were only used when creating an instance, and not after it was
|
|
|
74ca47 |
started.
|
|
|
74ca47 |
|
|
|
74ca47 |
https://pagure.io/389-ds-base/issue/49257
|
|
|
74ca47 |
|
|
|
74ca47 |
Reviewed by: tbordaz(Thanks!)
|
|
|
74ca47 |
---
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/instance.c | 19 +++++++++----
|
|
|
74ca47 |
.../servers/slapd/back-ldbm/ldbm_instance_config.c | 32 ++++++++++++++++++++--
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/start.c | 2 +-
|
|
|
74ca47 |
3 files changed, 44 insertions(+), 9 deletions(-)
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/instance.c b/ldap/servers/slapd/back-ldbm/instance.c
|
|
|
74ca47 |
index f79d048..8b38644 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/instance.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/instance.c
|
|
|
74ca47 |
@@ -302,12 +302,19 @@ ldbm_instance_startall(struct ldbminfo *li)
|
|
|
74ca47 |
inst = (ldbm_instance *) object_get_data(inst_obj);
|
|
|
74ca47 |
ldbm_instance_set_flags(inst);
|
|
|
74ca47 |
rc1 = ldbm_instance_start(inst->inst_be);
|
|
|
74ca47 |
- if (rc1 != 0) {
|
|
|
74ca47 |
- rc = rc1;
|
|
|
74ca47 |
- } else {
|
|
|
74ca47 |
- vlv_init(inst);
|
|
|
74ca47 |
- slapi_mtn_be_started(inst->inst_be);
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
+ if (rc1 != 0) {
|
|
|
74ca47 |
+ rc = rc1;
|
|
|
74ca47 |
+ } else {
|
|
|
74ca47 |
+ if(ldbm_instance_config_load_dse_info(inst) != 0){
|
|
|
74ca47 |
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_startall",
|
|
|
74ca47 |
+ "Loading database instance configuration failed for (%s)\n",
|
|
|
74ca47 |
+ inst->inst_name);
|
|
|
74ca47 |
+ rc = -1;
|
|
|
74ca47 |
+ } else {
|
|
|
74ca47 |
+ vlv_init(inst);
|
|
|
74ca47 |
+ slapi_mtn_be_started(inst->inst_be);
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
inst_obj = objset_next_obj(li->li_instance_set, inst_obj);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
|
|
|
74ca47 |
index 55f1887..49a6cac 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
|
|
|
74ca47 |
@@ -72,6 +72,18 @@ ldbm_instance_config_cachesize_set(void *arg, void *value, char *errorbuf, int p
|
|
|
74ca47 |
/* Do whatever we can to make sure the data is ok. */
|
|
|
74ca47 |
|
|
|
74ca47 |
if (apply) {
|
|
|
74ca47 |
+ if (CONFIG_PHASE_RUNNING == phase) {
|
|
|
74ca47 |
+ if (val > 0 && inst->inst_li->li_cache_autosize) {
|
|
|
74ca47 |
+ /* We are auto-tuning the cache, so this change would be overwritten - return an error */
|
|
|
74ca47 |
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
|
|
|
74ca47 |
+ "Error: \"nsslapd-cachesize\" can not be updated while \"nsslapd-cache-autosize\" is set "
|
|
|
74ca47 |
+ "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".");
|
|
|
74ca47 |
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_config_cachesize_set",
|
|
|
74ca47 |
+ "\"nsslapd-cachesize\" can not be set while \"nsslapd-cache-autosize\" is set "
|
|
|
74ca47 |
+ "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".\n");
|
|
|
74ca47 |
+ return LDAP_UNWILLING_TO_PERFORM;
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
cache_set_max_entries(&(inst->inst_cache), val);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -87,7 +99,11 @@ ldbm_instance_config_cachememsize_get(void *arg)
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
static int
|
|
|
74ca47 |
-ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, int phase, int apply)
|
|
|
74ca47 |
+ldbm_instance_config_cachememsize_set(void *arg,
|
|
|
74ca47 |
+ void *value,
|
|
|
74ca47 |
+ char *errorbuf,
|
|
|
74ca47 |
+ int phase,
|
|
|
74ca47 |
+ int apply)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
ldbm_instance *inst = (ldbm_instance *) arg;
|
|
|
74ca47 |
int retval = LDAP_SUCCESS;
|
|
|
74ca47 |
@@ -107,6 +123,18 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
|
|
|
74ca47 |
if (apply) {
|
|
|
74ca47 |
+ if (CONFIG_PHASE_RUNNING == phase) {
|
|
|
74ca47 |
+ if (val > 0 && inst->inst_li->li_cache_autosize) {
|
|
|
74ca47 |
+ /* We are auto-tuning the cache, so this change would be overwritten - return an error */
|
|
|
74ca47 |
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
|
|
|
74ca47 |
+ "Error: \"nsslapd-cachememsize\" can not be updated while \"nsslapd-cache-autosize\" is set "
|
|
|
74ca47 |
+ "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".");
|
|
|
74ca47 |
+ slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_config_cachememsize_set",
|
|
|
74ca47 |
+ "\"nsslapd-cachememsize\" can not be set while \"nsslapd-cache-autosize\" is set "
|
|
|
74ca47 |
+ "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".\n");
|
|
|
74ca47 |
+ return LDAP_UNWILLING_TO_PERFORM;
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
+ }
|
|
|
74ca47 |
if (val > inst->inst_cache.c_maxsize) {
|
|
|
74ca47 |
delta = val - inst->inst_cache.c_maxsize;
|
|
|
74ca47 |
delta_original = delta;
|
|
|
74ca47 |
@@ -825,7 +853,7 @@ ldbm_instance_modify_config_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryB
|
|
|
74ca47 |
continue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
- /* This assumes there is only one bval for this mod. */
|
|
|
74ca47 |
+ /* This assumes there is only one bval for this mod. */
|
|
|
74ca47 |
if (mods[i]->mod_bvalues == NULL) {
|
|
|
74ca47 |
/* This avoids the null pointer deref.
|
|
|
74ca47 |
* In ldbm_config.c ldbm_config_set, it checks for the NULL.
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
|
|
|
74ca47 |
index 1834a19..d4e8bb8 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/start.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/start.c
|
|
|
74ca47 |
@@ -169,7 +169,7 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk physical memory\n", mi->system_total_bytes / 1024);
|
|
|
74ca47 |
- slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk avaliable\n", mi->system_available_bytes / 1024);
|
|
|
74ca47 |
+ slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk available\n", mi->system_available_bytes / 1024);
|
|
|
74ca47 |
|
|
|
74ca47 |
/* We've now calculated the autotuning values. Do we need to apply it?
|
|
|
74ca47 |
* we use the logic of "if size is 0, or autosize is > 0. This way three
|
|
|
74ca47 |
--
|
|
|
74ca47 |
2.9.4
|
|
|
74ca47 |
|