summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-11-03 15:54:40 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2016-01-11 06:31:57 +1100
commitd72b3bd9259da4d53a32a8f73bd93bf8ef9129e9 (patch)
tree693df11b4b2e3cb1a9a703f069050d963361a17a
parenta1ddc5e6164ef982dc29dd658d391abff06a7484 (diff)
downloadmongo-d72b3bd9259da4d53a32a8f73bd93bf8ef9129e9.tar.gz
Merge pull request #2286 from wiredtiger/WT-2196-size-stat-lsm
(cherry picked from commit b1de96c) WT-2196 Backport to 3.0. Fix size-only statistics when there are LSM tables.
-rw-r--r--src/block/block_open.c6
-rw-r--r--src/lsm/lsm_tree.c5
-rw-r--r--src/os_posix/os_filesize.c7
-rw-r--r--src/os_win/os_filesize.c7
-rw-r--r--src/schema/schema_stat.c23
5 files changed, 27 insertions, 21 deletions
diff --git a/src/block/block_open.c b/src/block/block_open.c
index 4f4b7c57279..8b7d4beeac8 100644
--- a/src/block/block_open.c
+++ b/src/block/block_open.c
@@ -424,9 +424,13 @@ int
__wt_block_manager_size(
WT_SESSION_IMPL *session, const char *filename, WT_DSRC_STATS *stats)
{
+ WT_DECL_RET;
wt_off_t filesize;
- WT_RET(__wt_filesize_name(session, filename, &filesize));
+ ret = __wt_filesize_name(session, filename, &filesize);
+ if (ret != 0)
+ WT_RET_MSG(session, ret, "%s: file size", filename);
+
WT_STAT_SET(stats, block_size, filesize);
return (0);
diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c
index d3979da0da1..5cff7ccfae3 100644
--- a/src/lsm/lsm_tree.c
+++ b/src/lsm/lsm_tree.c
@@ -206,6 +206,7 @@ int
__wt_lsm_tree_set_chunk_size(
WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk)
{
+ WT_DECL_RET;
wt_off_t size;
const char *filename;
@@ -213,7 +214,9 @@ __wt_lsm_tree_set_chunk_size(
if (!WT_PREFIX_SKIP(filename, "file:"))
WT_RET_MSG(session, EINVAL,
"Expected a 'file:' URI: %s", chunk->uri);
- WT_RET(__wt_filesize_name(session, filename, &size));
+ ret = __wt_filesize_name(session, filename, &size);
+ if (ret != 0)
+ WT_RET_MSG(session, ret, "%s: file size", filename);
chunk->size = (uint64_t)size;
diff --git a/src/os_posix/os_filesize.c b/src/os_posix/os_filesize.c
index b01fc91514b..09174ffcd90 100644
--- a/src/os_posix/os_filesize.c
+++ b/src/os_posix/os_filesize.c
@@ -47,10 +47,9 @@ __wt_filesize_name(
__wt_free(session, path);
- if (ret == 0) {
+ if (ret == 0)
*sizep = sb.st_size;
- return (0);
- }
- WT_RET_MSG(session, ret, "%s: fstat", filename);
+ /* Some callers expect failure, so don't log an error message. */
+ return (ret);
}
diff --git a/src/os_win/os_filesize.c b/src/os_win/os_filesize.c
index dfeadc31fc4..c51303d7215 100644
--- a/src/os_win/os_filesize.c
+++ b/src/os_win/os_filesize.c
@@ -47,11 +47,10 @@ __wt_filesize_name(
__wt_free(session, path);
- if (ret != 0) {
+ if (ret != 0)
*sizep =
((int64_t)data.nFileSizeHigh << 32) | data.nFileSizeLow;
- return (0);
- }
- WT_RET_MSG(session, __wt_errno(), "%s: GetFileAttributesEx", filename);
+ /* Some callers expect failure, so don't log an error message. */
+ return (ret);
}
diff --git a/src/schema/schema_stat.c b/src/schema/schema_stat.c
index dba1dfe5f55..bd1f5299fe2 100644
--- a/src/schema/schema_stat.c
+++ b/src/schema/schema_stat.c
@@ -90,18 +90,19 @@ __curstat_size_only(WT_SESSION_IMPL *session,
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.
+ * Get the size of the underlying file. This will fail for anything
+ * other than simple tables (LSM for example) and will fail if there
+ * are concurrent schema level operations (for example drop). That is
+ * fine - failing here results in falling back to the slow path of
+ * opening the handle.
*/
- WT_ERR(__wt_filesize_name(session, namebuf.data, &filesize));
-
- /* Setup and populate the statistics structure */
- __wt_stat_init_dsrc_stats(&cst->u.dsrc_stats);
- WT_STAT_SET(&cst->u.dsrc_stats, block_size, filesize);
- __wt_curstat_dsrc_final(cst);
-
- *was_fast = true;
+ if (__wt_filesize_name(session, namebuf.data, &filesize) == 0) {
+ /* Setup and populate the statistics structure */
+ __wt_stat_init_dsrc_stats(&cst->u.dsrc_stats);
+ WT_STAT_SET(&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);