From b744e0dffefe4e70c1279fd67491b1e8dc1ad866 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Thu, 23 May 2013 15:16:35 -0400 Subject: [PATCH] Ticket 47326 - idl switch does not work Bug Description: Setting nsslapd-idl-switch to "old" always gets converted to "new", as the server tries to update the idl type. This makes it impossible to test the "old" idl processes. Fix Description: Added a new ldbm config setting to control if we do the upgrade check or not: "nsslapd-idl-update". The default is "on". This still allows the server to update the type by default, but if you must use "old", then you must turn the "update" off. Also did some minor code cleanup, and fixed some small memory leaks. https://fedorahosted.org/389/ticket/47326 Reviewed by: ? --- ldap/servers/slapd/back-ldbm/back-ldbm.h | 15 ++++++++------- ldap/servers/slapd/back-ldbm/dblayer.c | 22 +++++++++++++++++----- ldap/servers/slapd/back-ldbm/id2entry.c | 4 ++-- ldap/servers/slapd/back-ldbm/ldbm_attr.c | 2 +- ldap/servers/slapd/back-ldbm/ldbm_config.c | 21 +++++++++++++++++++++ ldap/servers/slapd/back-ldbm/ldbm_config.h | 1 + ldap/servers/slapd/back-ldbm/upgrade.c | 13 ++++++++----- 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index 871d489..e565360 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -645,13 +645,14 @@ struct ldbminfo { int li_fat_lock; /* 608146 -- make this configurable, first */ int li_legacy_errcode; /* 615428 -- in case legacy err code is expected */ Slapi_Counter *li_global_usn_counter; /* global USN counter */ - int li_reslimit_allids_handle; /* allids aka idlistscan */ - int li_pagedlookthroughlimit; - int li_pagedallidsthreshold; - int li_reslimit_pagedlookthrough_handle; - int li_reslimit_pagedallids_handle; /* allids aka idlistscan */ - int li_rangelookthroughlimit; - int li_reslimit_rangelookthrough_handle; + int li_reslimit_allids_handle; /* allids aka idlistscan */ + int li_pagedlookthroughlimit; + int li_pagedallidsthreshold; + int li_reslimit_pagedlookthrough_handle; + int li_reslimit_pagedallids_handle; /* allids aka idlistscan */ + int li_rangelookthroughlimit; + int li_reslimit_rangelookthrough_handle; + int li_idl_update; }; /* li_flags could store these bits defined in ../slapi-plugin.h diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 99902d9..2b0699c 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -2091,6 +2091,7 @@ int dblayer_instance_start(backend *be, int mode) LDAPDebug(LDAP_DEBUG_ANY, "Instance %s does not have the " "expected version\n", inst->inst_name, 0, 0); PR_ASSERT(0); + slapi_ch_free_string(&dataversion); return_value = -1; goto errout; } @@ -2100,6 +2101,7 @@ int dblayer_instance_start(backend *be, int mode) "%s is on, while the instance %s is in the DN format. " "Please run dn2rdn to convert the database format.\n", CONFIG_ENTRYRDN_SWITCH, inst->inst_name); + slapi_ch_free_string(&dataversion); return_value = -1; goto errout; } @@ -2109,6 +2111,7 @@ int dblayer_instance_start(backend *be, int mode) "%s is off, while the instance %s is in the RDN " "format. Please change the value to on in dse.ldif.\n", CONFIG_ENTRYRDN_SWITCH, inst->inst_name); + slapi_ch_free_string(&dataversion); return_value = -1; goto errout; } @@ -2976,6 +2979,7 @@ dblayer_remove_env(struct ldbminfo *li) static int _dblayer_set_db_callbacks(dblayer_private *priv, DB *dbp, struct attrinfo *ai) { + int idl_use_new = 0; int rc = 0; /* With the new idl design, the large 8Kbyte pages we use are not @@ -3005,16 +3009,24 @@ _dblayer_set_db_callbacks(dblayer_private *priv, DB *dbp, struct attrinfo *ai) if (rc) return rc; #endif - - if (idl_get_idl_new() && !(ai->ai_indexmask & INDEX_VLV)) { + /* + * If using the "new" idl, set the flags and the compare function. + * If using the "old" idl, we still need to set the index DB flags + * for the attribute "entryRDN". + */ + if ( ((idl_use_new = idl_get_idl_new()) || + 0 == strcasecmp(ai->ai_type, LDBM_ENTRYRDN_STR)) && + !(ai->ai_indexmask & INDEX_VLV)) + { + /* set the flags */ rc = dbp->set_flags(dbp, DB_DUP | DB_DUPSORT); if (rc) return rc; - + /* set the compare function */ if (ai->ai_dup_cmp_fn) { /* If set, use the special dup compare callback */ rc = dbp->set_dup_compare(dbp, ai->ai_dup_cmp_fn); - } else { + } else if(idl_use_new) { rc = dbp->set_dup_compare(dbp, idl_new_compare_dups); } if (rc) @@ -6950,7 +6962,7 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char * { adjust_idl_switch(ldbmversion, li); slapi_ch_free_string(&ldbmversion); - slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&dataversion); } } diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c index dae558c..281bb1b 100644 --- a/ldap/servers/slapd/back-ldbm/id2entry.c +++ b/ldap/servers/slapd/back-ldbm/id2entry.c @@ -367,7 +367,7 @@ id2entry( backend *be, ID id, back_txn *txn, int *err ) ee = slapi_str2entry( data.dptr, SLAPI_STR2ENTRY_NO_ENTRYDN ); } else { char *normdn = NULL; - Slapi_RDN * srdn = NULL; + Slapi_RDN * srdn = NULL; struct backdn *bdn = dncache_find_id(&inst->inst_dncache, id); if (bdn) { normdn = slapi_ch_strdup(slapi_sdn_get_dn(bdn->dn_sdn)); @@ -407,7 +407,7 @@ id2entry( backend *be, ID id, back_txn *txn, int *err ) SLAPI_STR2ENTRY_NO_ENTRYDN ); slapi_ch_free_string(&rdn); slapi_ch_free_string(&normdn); - slapi_rdn_free(&srdn); + slapi_rdn_free(&srdn); } } else { ee = slapi_str2entry( data.dptr, 0 ); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attr.c b/ldap/servers/slapd/back-ldbm/ldbm_attr.c index 7433ec7..09f1a48 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c @@ -202,7 +202,7 @@ attr_index_config( slapi_attr_init(&a->ai_sattr, attrValue->bv_val); /* * we can't just set a->ai_type to the type from a->ai_sattr - * if the type has attroptions or subtypes, ai_sattr.a_type will + * if the type has attr options or subtypes, ai_sattr.a_type will * contain them - but for the purposes of indexing, we don't want them */ a->ai_type = slapi_attr_basetype( attrValue->bv_val, NULL, 0 ); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index b72984b..08fc536 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -872,6 +872,26 @@ static void *ldbm_config_db_private_import_mem_get(void *arg) return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_import_mem); } +static void *ldbm_config_idl_get_update(void *arg) +{ + struct ldbminfo *li = (struct ldbminfo *) arg; + + return (void *) ((uintptr_t)li->li_idl_update); +} + +static int ldbm_config_idl_set_update(void *arg, void *value, char *errorbuf, int phase, int apply) +{ + struct ldbminfo *li = (struct ldbminfo *) arg; + int retval = LDAP_SUCCESS; + int val = (int) ((uintptr_t)value); + + if (apply) { + li->li_idl_update = val; + } + + return retval; +} + static int ldbm_config_db_private_import_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; @@ -1350,6 +1370,7 @@ static config_info ldbm_config[] = { {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0}, {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_IDL_UPDATE, CONFIG_TYPE_ONOFF, "on", &ldbm_config_idl_get_update, &ldbm_config_idl_set_update, 0}, {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0}, diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h index 204f64d..17883cb 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.h +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h @@ -140,6 +140,7 @@ struct config_info { #define CONFIG_DB_TX_MAX "nsslapd-db-tx-max" #define CONFIG_IDL_SWITCH "nsslapd-idl-switch" +#define CONFIG_IDL_UPDATE "nsslapd-idl-update" #define CONFIG_BYPASS_FILTER_TEST "nsslapd-search-bypass-filter-test" #define CONFIG_USE_VLV_INDEX "nsslapd-search-use-vlv-index" #define CONFIG_SERIAL_LOCK "nsslapd-serial-lock" diff --git a/ldap/servers/slapd/back-ldbm/upgrade.c b/ldap/servers/slapd/back-ldbm/upgrade.c index a10ee9b..4f322fa 100644 --- a/ldap/servers/slapd/back-ldbm/upgrade.c +++ b/ldap/servers/slapd/back-ldbm/upgrade.c @@ -321,6 +321,11 @@ adjust_idl_switch(char *ldbmversion, struct ldbminfo *li) { int rval = 0; + if( !li->li_idl_update ){ + /* we are not overriding the idl type */ + return rval; + } + li->li_flags |= LI_FORCE_MOD_CONFIG; if ((0 == PL_strncasecmp(ldbmversion, BDB_IMPL, strlen(BDB_IMPL))) || (0 == PL_strcmp(ldbmversion, LDBM_VERSION))) /* db: new idl */ @@ -328,11 +333,9 @@ adjust_idl_switch(char *ldbmversion, struct ldbminfo *li) if (!idl_get_idl_new()) /* config: old idl */ { replace_ldbm_config_value(CONFIG_IDL_SWITCH, "new", li); - LDAPDebug(LDAP_DEBUG_ANY, + LDAPDebug(LDAP_DEBUG_ANY, "Warning: Dbversion %s does not meet nsslapd-idl-switch: \"old\"; " - "nsslapd-idl-switch is updated to \"new\"\n", - - ldbmversion, 0, 0); + "nsslapd-idl-switch is updated to \"new\"\n", ldbmversion, 0, 0); } } else if ((0 == strcmp(ldbmversion, LDBM_VERSION_OLD)) || @@ -354,7 +357,7 @@ adjust_idl_switch(char *ldbmversion, struct ldbminfo *li) LDAPDebug(LDAP_DEBUG_ANY, "Warning: Dbversion %s is not supported\n", ldbmversion, 0, 0); - rval = 1; + rval = -1; } /* ldbminfo is a common resource; should clean up when the job is done */ -- 1.7.1