diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-11-02 11:55:14 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-11-02 11:55:14 +1100 |
commit | fb6ebe75207c3221314ed318595489a838ef1db0 (patch) | |
tree | 6b9b210b15f9b9685b9a5dd707001297127ee1d3 /src/third_party/wiredtiger/src/schema | |
parent | 4fbfa13ec0f819080a35ed8b528a030797e483a6 (diff) | |
download | mongo-fb6ebe75207c3221314ed318595489a838ef1db0.tar.gz |
Import wiredtiger-wiredtiger-mongodb-3.2.0-rc1-194-g0dc3f20.tar.gz from wiredtiger branch mongodb-3.2
Diffstat (limited to 'src/third_party/wiredtiger/src/schema')
-rw-r--r-- | src/third_party/wiredtiger/src/schema/schema_open.c | 47 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/schema/schema_stat.c | 68 |
2 files changed, 107 insertions, 8 deletions
diff --git a/src/third_party/wiredtiger/src/schema/schema_open.c b/src/third_party/wiredtiger/src/schema/schema_open.c index a86cff4d723..ba8664f2e39 100644 --- a/src/third_party/wiredtiger/src/schema/schema_open.c +++ b/src/third_party/wiredtiger/src/schema/schema_open.c @@ -260,11 +260,11 @@ err: __wt_scr_free(session, &buf); } /* - * __wt_schema_open_index -- - * Open one or more indices for a table. + * __schema_open_index -- + * Open one or more indices for a table (internal version). */ -int -__wt_schema_open_index(WT_SESSION_IMPL *session, +static int +__schema_open_index(WT_SESSION_IMPL *session, WT_TABLE *table, const char *idxname, size_t len, WT_INDEX **indexp) { WT_CURSOR *cursor; @@ -387,6 +387,21 @@ err: __wt_scr_free(session, &tmp); } /* + * __wt_schema_open_index -- + * Open one or more indices for a table. + */ +int +__wt_schema_open_index(WT_SESSION_IMPL *session, + WT_TABLE *table, const char *idxname, size_t len, WT_INDEX **indexp) +{ + WT_DECL_RET; + + WT_WITH_TXN_ISOLATION(session, WT_ISO_READ_UNCOMMITTED, + ret = __schema_open_index(session, table, idxname, len, indexp)); + return (ret); +} + +/* * __wt_schema_open_indices -- * Open the indices for a table. */ @@ -397,11 +412,11 @@ __wt_schema_open_indices(WT_SESSION_IMPL *session, WT_TABLE *table) } /* - * __wt_schema_open_table -- - * Open a named table. + * __schema_open_table -- + * Open a named table (internal version). */ -int -__wt_schema_open_table(WT_SESSION_IMPL *session, +static int +__schema_open_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) { WT_CONFIG cparser; @@ -597,3 +612,19 @@ err: __wt_schema_release_table(session, table); WT_RET(ENOENT); WT_RET_MSG(session, ENOENT, "%s not found in table", uri); } + +/* + * __wt_schema_open_table -- + * Open a named table. + */ +int +__wt_schema_open_table(WT_SESSION_IMPL *session, + const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) +{ + WT_DECL_RET; + + WT_WITH_TXN_ISOLATION(session, WT_ISO_READ_UNCOMMITTED, + ret = __schema_open_table( + session, name, namelen, ok_incomplete, tablep)); + return (ret); +} diff --git a/src/third_party/wiredtiger/src/schema/schema_stat.c b/src/third_party/wiredtiger/src/schema/schema_stat.c index 0c2c5fe78c0..d14b81d389f 100644 --- a/src/third_party/wiredtiger/src/schema/schema_stat.c +++ b/src/third_party/wiredtiger/src/schema/schema_stat.c @@ -53,6 +53,63 @@ err: __wt_scr_free(session, &buf); } /* + * __curstat_size_only -- + * For very simple tables we can avoid getting table handles if + * configured to only retrieve the size. It's worthwhile because + * workloads that create and drop a lot of tables can put a lot of + * pressure on the table list lock. + */ +static int +__curstat_size_only(WT_SESSION_IMPL *session, + const char *uri, bool *was_fast,WT_CURSOR_STAT *cst) +{ + WT_CONFIG cparser; + WT_CONFIG_ITEM ckey, colconf, cval; + WT_DECL_RET; + WT_ITEM namebuf; + wt_off_t filesize; + char *tableconf; + + WT_CLEAR(namebuf); + *was_fast = false; + + /* Retrieve the metadata for this table. */ + WT_RET(__wt_metadata_search(session, uri, &tableconf)); + + /* + * The fast path only works if the table consists of a single file + * and does not have any indexes. The absence of named columns is how + * we determine that neither of those conditions can be satisfied. + */ + WT_ERR(__wt_config_getones(session, tableconf, "columns", &colconf)); + WT_ERR(__wt_config_subinit(session, &cparser, &colconf)); + if ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0) + goto err; + + /* Build up the file name from the table URI. */ + WT_ERR(__wt_buf_fmt( + session, &namebuf, "%s.wt", uri + strlen("table:"))); + /* + * Get the size of the underlying file. There is nothing stopping a + * race with schema level table operations (for example drop) if there + * is a race there will be an error message generated. + */ + WT_ERR(__wt_filesize_name(session, namebuf.data, &filesize)); + + /* Setup and populate the statistics structure */ + __wt_stat_dsrc_init_single(&cst->u.dsrc_stats); + cst->u.dsrc_stats.block_size = filesize; + __wt_curstat_dsrc_final(cst); + + *was_fast = true; + +err: __wt_free(session, tableconf); + __wt_buf_free(session, &namebuf); + + return (ret); +} + +/* * __wt_curstat_table_init -- * Initialize the statistics for a table. */ @@ -67,6 +124,17 @@ __wt_curstat_table_init(WT_SESSION_IMPL *session, WT_TABLE *table; u_int i; const char *name; + bool was_fast; + + /* + * If only gathering table size statistics, try a fast path that + * avoids the schema and table list locks. + */ + if (F_ISSET(cst, WT_CONN_STAT_SIZE)) { + WT_RET(__curstat_size_only(session, uri, &was_fast, cst)); + if (was_fast) + return (0); + } name = uri + strlen("table:"); WT_RET(__wt_schema_get_table( |