From 8141cd4db7ff32d8ed5dc60788a774ee9023b083 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 4 Sep 2008 07:43:19 +0000 Subject: [PATCH] make additional checking optional (more on ITS#5860) --- doc/man/man5/slapo-pcache.5 | 30 +++++++++++++++++++----------- servers/slapd/overlays/pcache.c | 11 +++++++++-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/doc/man/man5/slapo-pcache.5 b/doc/man/man5/slapo-pcache.5 index eb2b0f5aa5..2395f062da 100644 --- a/doc/man/man5/slapo-pcache.5 +++ b/doc/man/man5/slapo-pcache.5 @@ -68,10 +68,29 @@ returned is less than . Consistency check is performed every proxycache \fBbdb 10000 1 50 100\fP .RE +.TP +.B proxyattrset +Used to associate a set of attributes with an . Each attribute +set is associated with an integer from 0 to -1. These indices are +used by the \fBproxytemplate\fP directive to define cacheable templates. +A set of attributes cannot be empty. A set of attributes can contain the +special attributes "*" (all user attributes), "+" (all operational attributes) +or both; in the latter case, any other attribute is redundant and should +be avoided for clarity. A set of attributes can contain "1.1" as the only +attribute; in this case, only the presence of the entries is cached. + .TP .B proxycachequeries Specify the maximum number of queries to cache. The default is 10000. +.TP +.B proxycheckcacheability { TRUE | FALSE } +Check whether the results of a query being cached can actually be returned +from the cache by the proxy DSA. When enabled, the entries being returned +while caching the results of a query are checked to ensure consistency +with the schema known to the proxy DSA. In case of failure, the query +is not cached. By default, the check is off. + .TP .B proxysavequeries { TRUE | FALSE } Specify whether the cached queries should be saved across restarts @@ -90,17 +109,6 @@ directives are not changed neither in order nor in contents. If new sets and templates are added, or if other details of the pcache overlay configuration changed, this feature should not be affected. -.TP -.B proxyattrset -Used to associate a set of attributes with an . Each attribute -set is associated with an integer from 0 to -1. These indices are -used by the \fBproxytemplate\fP directive to define cacheable templates. -A set of attributes cannot be empty. A set of attributes can contain the -special attributes "*" (all user attributes), "+" (all operational attributes) -or both; in the latter case, any other attribute is redundant and should -be avoided for clarity. A set of attributes can contain "1.1" as the only -attribute; in this case, only the presence of the entries is cached. - .TP .B proxytemplate [ []] Specifies a cacheable template and "time to live" of queries diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 22b8355865..450290fcc3 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -182,6 +182,7 @@ typedef struct cache_manager_s { unsigned long num_cached_queries; /* total number of cached queries */ unsigned long max_queries; /* upper bound on # of cached queries */ int save_queries; /* save cached queries across restarts */ + int check_cacheability; /* check whether a query is cacheable */ int numattrsets; /* number of attribute sets */ int cur_entries; /* current number of entries cached */ int max_entries; /* max number of entries cached */ @@ -1963,7 +1964,7 @@ pcache_op_cleanup( Operation *op, SlapReply *rs ) { if ( !si->over ) { /* check if the entry contains undefined * attributes/objectClasses (ITS#5680) */ - if ( test_filter( op, rs->sr_entry, si->query.filter ) != LDAP_COMPARE_TRUE ) { + if ( cm->check_cacheability && test_filter( op, rs->sr_entry, si->query.filter ) != LDAP_COMPARE_TRUE ) { Debug( pcache_debug, "%s: query not cacheable because of schema issues in DN \"%s\"\n", op->o_log_prefix, rs->sr_entry->e_name.bv_val, 0 ); goto over; @@ -2645,6 +2646,11 @@ static ConfigTable pccfg[] = { "( OLcfgOvAt:2.6 NAME 'olcProxySaveQueries' " "DESC 'Save cached queries for hot restart' " "SYNTAX OMsBoolean )", NULL, NULL }, + { "proxyCheckCacheability", "TRUE|FALSE", + 2, 2, 0, ARG_ON_OFF|ARG_OFFSET, (void *)offsetof(cache_manager, check_cacheability), + "( OLcfgOvAt:2.7 NAME 'olcProxyCheckCacheability' " + "DESC 'Check whether the results of a query are cacheable, e.g. for schema issues' " + "SYNTAX OMsBoolean )", NULL, NULL }, { NULL, NULL, 0, 0, 0, ARG_IGNORED } }; @@ -2664,7 +2670,7 @@ static ConfigOCs pcocs[] = { "DESC 'ProxyCache configuration' " "SUP olcOverlayConfig " "MUST ( olcProxyCache $ olcProxyAttrset $ olcProxyTemplate ) " - "MAY ( olcProxyResponseCB $ olcProxyCacheQueries $ olcProxySaveQueries ) )", + "MAY ( olcProxyResponseCB $ olcProxyCacheQueries $ olcProxySaveQueries $ olcProxyCheckCacheability ) )", Cft_Overlay, pccfg, NULL, pc_cfadd }, { "( OLcfgOvOc:2.2 " "NAME 'olcPcacheDatabase' " @@ -3157,6 +3163,7 @@ pcache_db_init( cm->cur_entries = 0; cm->max_queries = 10000; cm->save_queries = 0; + cm->check_cacheability = 0; cm->response_cb = PCACHE_RESPONSE_CB_TAIL; cm->defer_db_open = 1; cm->cc_period = 1000; -- 2.39.5