andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0053-Ticket-49257-Reject-dbcachesize-updates-while-auto-c.patch

61f723
From 550d30d3aa27cd69057604e1ee7d5ca43711d718 Mon Sep 17 00:00:00 2001
61f723
From: Mark Reynolds <mreynolds@redhat.com>
61f723
Date: Mon, 15 May 2017 13:30:22 -0400
61f723
Subject: [PATCH] Ticket 49257 - Reject dbcachesize updates while auto cache
61f723
 sizing is enabled
61f723
61f723
Description:  We should reject updates to nsslapd-dbcachesize while auto cache sizing
61f723
              is in effect.  This is because at startup we would overwrite the
61f723
              manually set dbcache size anyway.  It would never take effect, so it
61f723
              should be rejected.
61f723
61f723
https://pagure.io/389-ds-base/issue/49257
61f723
61f723
Reviewed by: tbordaz & firstyear(Thanks!!)
61f723
---
61f723
 ldap/servers/slapd/back-ldbm/ldbm_config.c | 13 ++++++++++++-
61f723
 1 file changed, 12 insertions(+), 1 deletion(-)
61f723
61f723
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
61f723
index f7edd9e..6c1dda0 100644
61f723
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
61f723
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
61f723
@@ -420,7 +420,7 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
61f723
         /* Stop the user configuring a stupidly small cache */
61f723
         /* min: 8KB (page size) * def thrd cnts (threadnumber==20). */
61f723
 #define DBDEFMINSIZ     500000
61f723
-        /* We allow a value of 0, because the autotuting in start.c will
61f723
+        /* We allow a value of 0, because the autotuning in start.c will
61f723
          * register that, and trigger the recalculation of the dbcachesize as
61f723
          * needed on the next start up.
61f723
          */
61f723
@@ -443,7 +443,18 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
61f723
                 return LDAP_UNWILLING_TO_PERFORM;
61f723
             }
61f723
         }
61f723
+
61f723
         if (CONFIG_PHASE_RUNNING == phase) {
61f723
+            if (val > 0 && li->li_cache_autosize) {
61f723
+                /* We are auto-tuning the cache, so this change would be overwritten - return an error */
61f723
+                slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
61f723
+                    "Error: \"nsslapd-dbcachesize\" can not be updated while \"nsslapd-cache-autosize\" is set "
61f723
+                    "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".");
61f723
+                slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_dbcachesize_set",
61f723
+                    "\"nsslapd-dbcachesize\" can not be set while \"nsslapd-cache-autosize\" is set "
61f723
+                    "in \"cn=config,cn=ldbm database,cn=plugins,cn=config\".\n");
61f723
+                return LDAP_UNWILLING_TO_PERFORM;
61f723
+            }
61f723
             li->li_new_dbcachesize = val;
61f723
             if (val == 0) {
61f723
                 slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_config_dbcachesize_set", "cache size reset to 0, will be autosized on next startup.\n");
61f723
-- 
61f723
2.9.4
61f723