summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2013-02-16 08:04:52 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2013-02-16 08:04:52 +1100
commitbc27250c15cfdd31d9cd01430a592a437935496e (patch)
tree860ffdfe1a09769fd1f37f0014f4f4a9b0b88091
parente3bb7e72f918bd6655cd7137d65816b2afdf06f9 (diff)
downloadmongo-bc27250c15cfdd31d9cd01430a592a437935496e.tar.gz
Fix shared cache so that reserve size is always initialized properly.
Also change how we detect if shared cache is used. It used to rely on a name, now it will be used if the shared_cache configuration option was included by the user.
-rw-r--r--dist/api_data.py4
-rw-r--r--src/config/config_def.c10
-rw-r--r--src/conn/conn_cache.c2
-rw-r--r--src/conn/conn_cache_pool.c6
-rw-r--r--src/include/misc.h7
-rw-r--r--src/include/wiredtiger.in14
-rw-r--r--test/suite/test_shared_cache.py10
7 files changed, 36 insertions, 17 deletions
diff --git a/dist/api_data.py b/dist/api_data.py
index ada6f8a9b32..206a09230c9 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -262,8 +262,8 @@ connection_runtime_config = [
Config('reserve', '0', r'''
amount of cache this database is guaranteed to have available
from the shared cache. This setting is per database. Defaults
- to the chunk size'''),
- Config('name', '', r'''
+ to the chunk size''', type='int'),
+ Config('name', 'pool', r'''
name of a cache that is shared between databases'''),
Config('size', '500MB', r'''
maximum memory to allocate for the shared cache. Setting this
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 6ff187ab824..a5c1345d0a9 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -86,13 +86,13 @@ const char *
__wt_confdfl_connection_reconfigure =
"cache_size=100MB,error_prefix=,eviction_dirty_target=80,"
"eviction_target=80,eviction_trigger=95,shared_cache=(chunk=10MB,"
- "name=,reserve=0,size=500MB),verbose=";
+ "name=pool,reserve=0,size=500MB),verbose=";
WT_CONFIG_CHECK
__wt_confchk_shared_cache_subconfigs[] = {
{ "chunk", "int", "min=1MB,max=10TB", NULL },
{ "name", "string", NULL, NULL },
- { "reserve", "string", NULL, NULL },
+ { "reserve", "int", NULL, NULL },
{ "size", "int", "min=1MB,max=10TB", NULL },
{ NULL, NULL, NULL, NULL }
};
@@ -426,9 +426,9 @@ __wt_confdfl_wiredtiger_open =
"buffer_alignment=-1,cache_size=100MB,create=0,direct_io=,"
"error_prefix=,eviction_dirty_target=80,eviction_target=80,"
"eviction_trigger=95,extensions=,hazard_max=1000,logging=0,lsm_merge="
- ",mmap=,multiprocess=0,session_max=50,shared_cache=(chunk=10MB,name=,"
- "reserve=0,size=500MB),sync=,transactional=,use_environment_priv=0,"
- "verbose=";
+ ",mmap=,multiprocess=0,session_max=50,shared_cache=(chunk=10MB,"
+ "name=pool,reserve=0,size=500MB),sync=,transactional=,"
+ "use_environment_priv=0,verbose=";
WT_CONFIG_CHECK
__wt_confchk_wiredtiger_open[] = {
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c
index f20538a2354..8e256582a5a 100644
--- a/src/conn/conn_cache.c
+++ b/src/conn/conn_cache.c
@@ -32,7 +32,7 @@ __wt_cache_config(WT_CONNECTION_IMPL *conn, const char *cfg[])
if (F_ISSET(conn, WT_CONN_CACHE_POOL) &&
(ret = __wt_config_gets(session, cfg,
- "shared_cache.reserve", &cval)) == 0)
+ "shared_cache.reserve", &cval)) == 0 && cval.val != 0)
cache->cp_reserved = (uint64_t)cval.val;
else if ((ret = __wt_config_gets(session, cfg,
"shared_cache.chunk", &cval)) == 0)
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c
index 76ea6914c17..bb045065c1b 100644
--- a/src/conn/conn_cache_pool.c
+++ b/src/conn/conn_cache_pool.c
@@ -47,10 +47,12 @@ __wt_conn_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
if (F_ISSET(conn, WT_CONN_CACHE_POOL))
reconfiguring = 1;
else {
+ /* Only setup if a shared cache was explicitly configured. */
+ if (__wt_config_gets(session, WT_SKIP_DEFAULT_CONFIG(cfg),
+ "shared_cache", &cval) == WT_NOTFOUND)
+ return (0);
WT_RET_NOTFOUND_OK(
__wt_config_gets(session, cfg, "shared_cache.name", &cval));
- if (cval.len == 0)
- return (0);
/*
* NOTE: The allocations made when configuring and opening a
* cache pool don't really belong to the connection that
diff --git a/src/include/misc.h b/src/include/misc.h
index e42620b1d5f..3d0d8d3edd6 100644
--- a/src/include/misc.h
+++ b/src/include/misc.h
@@ -165,6 +165,13 @@
#define WT_DECL_RET int ret = 0
/*
+ * Skip the default configuration string in an list of configurations. The
+ * default config is always the first entry in the array, and the array always
+ * has an explicit NULL terminator, so this is safe.
+ */
+#define WT_SKIP_DEFAULT_CONFIG(c) &(c)[1]
+
+/*
* In diagnostic mode we track the locations from which hazard pointers and
* scratch buffers were acquired.
*/
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index db62acb6871..51d1df3a5b4 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -1053,10 +1053,10 @@ struct __wt_connection {
* shared cache is redistributed.,an integer between 1MB and 10TB;
* default \c 10MB.}@config{&nbsp;&nbsp;&nbsp;&nbsp;reserve, amount of
* cache this database is guaranteed to have available from the shared
- * cache. This setting is per database. Defaults to the chunk size.,a
- * string; default \c 0.}@config{&nbsp;&nbsp;&nbsp;&nbsp;name, name of a
- * cache that is shared between databases.,a string; default
- * empty.}@config{&nbsp;&nbsp;&nbsp;&nbsp;size, maximum memory to
+ * cache. This setting is per database. Defaults to the chunk size.,an
+ * integer; default \c 0.}@config{&nbsp;&nbsp;&nbsp;&nbsp;name, name of
+ * a cache that is shared between databases.,a string; default \c
+ * pool.}@config{&nbsp;&nbsp;&nbsp;&nbsp;size, maximum memory to
* allocate for the shared cache. Setting this will update the value if
* one is already set.,an integer between 1MB and 10TB; default \c
* 500MB.}@config{ ),,}
@@ -1266,10 +1266,10 @@ struct __wt_connection {
* cache is redistributed.,an integer between 1MB and 10TB; default \c
* 10MB.}@config{&nbsp;&nbsp;&nbsp;&nbsp;reserve, amount of cache this database
* is guaranteed to have available from the shared cache. This setting is per
- * database. Defaults to the chunk size.,a string; default \c
+ * database. Defaults to the chunk size.,an integer; default \c
* 0.}@config{&nbsp;&nbsp;&nbsp;&nbsp;name, name of a cache that is shared
- * between databases.,a string; default
- * empty.}@config{&nbsp;&nbsp;&nbsp;&nbsp;size, maximum memory to allocate for
+ * between databases.,a string; default \c
+ * pool.}@config{&nbsp;&nbsp;&nbsp;&nbsp;size, maximum memory to allocate for
* the shared cache. Setting this will update the value if one is already
* set.,an integer between 1MB and 10TB; default \c 500MB.}@config{ ),,}
* @config{sync, flush files to stable storage when closing or writing
diff --git a/test/suite/test_shared_cache.py b/test/suite/test_shared_cache.py
index cb1edc46ded..7bf54432e3a 100644
--- a/test/suite/test_shared_cache.py
+++ b/test/suite/test_shared_cache.py
@@ -209,5 +209,15 @@ class test_shared_cache(wttest.WiredTigerTestCase):
connection.reconfigure("shared_cache=(size=300M)")
self.closeConnections()
+ # Test default config values
+ def test_shared_cache11(self):
+ nops = 1000
+ self.openConnections(['WT_TEST1', 'WT_TEST2'], pool_opts=',shared_cache=()')
+
+ for sess in self.sessions:
+ sess.create(self.uri, "key_format=S,value_format=S")
+ self.add_records(sess, 0, nops)
+ self.closeConnections()
+
if __name__ == '__main__':
wttest.run()