summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/lsm/lsm_tree.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2017-12-14 11:34:35 -0500
committerLuke Chen <luke.chen@mongodb.com>2017-12-14 11:34:35 -0500
commitec894eecfba4009e2ccd685e15351e4dae5848ad (patch)
treeb347f774ed408c0ff275d6889cc022ab8afe727b /src/third_party/wiredtiger/src/lsm/lsm_tree.c
parentfe40a36217a2b4e4064165340d44cc1442d84e13 (diff)
downloadmongo-ec894eecfba4009e2ccd685e15351e4dae5848ad.tar.gz
Import wiredtiger: 1a29eac4dc8cf82de437292da546e3f4039268a4 from branch mongodb-3.8
ref: 596a3c7c01..1a29eac4dc for: 3.7.1 WT-3079 Make sure eviction visits all trees WT-3133 Detect or track long latency operations WT-3295 Allow LSM to merge into custom data sources WT-3587 Remove HAVE_VERBOSE conditional compilation WT-3654 Fix warning in Windows build on evergreen WT-3716 Restore the WT_VERB_TEMPORARY verbose flag. WT-3720 flags macros cast flags to unsigned values, hiding warnings. WT-3732 Handle adding WT indices while cursors on the table are open WT-3734 Fix undefined behavior in verbose output WT-3738 Review internal session allocation accounting WT-3753 Building on Windows --enable-java WT-3772 Hot backup causes uncontrolled growth of WiredTigerPreplog files WT-3774 Enhance Python lookaside testing to cover cursor modify WT-3776 Cursor remove operation unpins page too early WT-3780 Improve error messages on invalid WT_CURSOR::modify usage WT-3783 Fix transaction isolation to use the correct enum WT-3786 Transactions with timestamps should read their writes WT-3787 test_compact02 failed as compaction halted due to eviction pressure WT-3790 Switch statistics to rdtsc from epoch calls WT-3793 WiredTiger page debug dump functions should unpack integer keys WT-3794 Coverity 1383547 and lint WT-3795 lint cleanups for the op-tracking software, reduce record write size.
Diffstat (limited to 'src/third_party/wiredtiger/src/lsm/lsm_tree.c')
-rw-r--r--src/third_party/wiredtiger/src/lsm/lsm_tree.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/src/third_party/wiredtiger/src/lsm/lsm_tree.c b/src/third_party/wiredtiger/src/lsm/lsm_tree.c
index c5b63df099f..cef5e51e214 100644
--- a/src/third_party/wiredtiger/src/lsm/lsm_tree.c
+++ b/src/third_party/wiredtiger/src/lsm/lsm_tree.c
@@ -28,6 +28,8 @@ __lsm_tree_discard_state(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
__wt_free(session, lsm_tree->key_format);
__wt_free(session, lsm_tree->value_format);
__wt_free(session, lsm_tree->collator_name);
+ __wt_free(session, lsm_tree->custom_prefix);
+ __wt_free(session, lsm_tree->custom_suffix);
__wt_free(session, lsm_tree->bloom_config);
__wt_free(session, lsm_tree->file_config);
@@ -208,14 +210,22 @@ err: __wt_scr_free(session, &tmp);
*/
int
__wt_lsm_tree_chunk_name(WT_SESSION_IMPL *session,
- WT_LSM_TREE *lsm_tree, uint32_t id, const char **retp)
+ WT_LSM_TREE *lsm_tree, uint32_t id, uint32_t generation, const char **retp)
{
WT_DECL_ITEM(tmp);
WT_DECL_RET;
WT_RET(__wt_scr_alloc(session, 0, &tmp));
- WT_ERR(__wt_buf_fmt(
- session, tmp, "file:%s-%06" PRIu32 ".lsm", lsm_tree->filename, id));
+
+ if (lsm_tree->custom_generation != 0 &&
+ generation >= lsm_tree->custom_generation)
+ WT_ERR(__wt_buf_fmt(session, tmp, "%s:%s-%06" PRIu32 "%s",
+ lsm_tree->custom_prefix, lsm_tree->filename, id,
+ lsm_tree->custom_suffix));
+ else
+ WT_ERR(__wt_buf_fmt(session, tmp, "file:%s-%06" PRIu32 ".lsm",
+ lsm_tree->filename, id));
+
WT_ERR(__wt_strndup(session, tmp->data, tmp->size, retp));
err: __wt_scr_free(session, &tmp);
@@ -229,16 +239,32 @@ err: __wt_scr_free(session, &tmp);
*/
int
__wt_lsm_tree_set_chunk_size(
- WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk)
+ WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk)
{
+ WT_DATA_SOURCE *dsrc;
wt_off_t size;
const char *filename;
- filename = chunk->uri;
- if (!WT_PREFIX_SKIP(filename, "file:"))
- WT_RET_MSG(session, EINVAL,
- "Expected a 'file:' URI: %s", chunk->uri);
- WT_RET(__wt_fs_size(session, filename, &size));
+ size = 0;
+ if (lsm_tree->custom_generation != 0 &&
+ chunk->generation >= lsm_tree->custom_generation) {
+ dsrc = __wt_schema_get_source(session, chunk->uri);
+ /*
+ * We can only retrieve a size if the data source exposes the
+ * information.
+ */
+ if (dsrc != NULL && dsrc->size != NULL) {
+ /* Call the callback. */
+ WT_RET(dsrc->size(
+ dsrc, (WT_SESSION*)session, chunk->uri, &size));
+ }
+ } else {
+ filename = chunk->uri;
+ if (!WT_PREFIX_SKIP(filename, "file:"))
+ WT_RET_MSG(session, EINVAL,
+ "Expected a 'file:' URI: %s", chunk->uri);
+ WT_RET(__wt_fs_size(session, filename, &size));
+ }
chunk->size = (uint64_t)size;
@@ -257,10 +283,13 @@ __lsm_tree_cleanup_old(WT_SESSION_IMPL *session, const char *uri)
WT_DECL_RET;
const char *cfg[] =
{ WT_CONFIG_BASE(session, WT_SESSION_drop), "force", NULL };
- bool exists;
+ bool exists, is_file;
- WT_RET(__wt_fs_exist(session, uri + strlen("file:"), &exists));
- if (exists)
+ exists = false;
+ is_file = WT_PREFIX_MATCH(uri, "file:");
+ if (is_file)
+ WT_RET(__wt_fs_exist(session, uri + strlen("file:"), &exists));
+ if (!is_file || exists)
WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_drop(session, uri, cfg));
return (ret);
@@ -280,7 +309,7 @@ __wt_lsm_tree_setup_chunk(
WT_RET(__wt_spin_init(session,
&chunk->timestamp_spinlock, "LSM chunk timestamp"));
WT_RET(__wt_lsm_tree_chunk_name(
- session, lsm_tree, chunk->id, &chunk->uri));
+ session, lsm_tree, chunk->id, chunk->generation, &chunk->uri));
/*
* If the underlying file exists, drop the chunk first - there may be
@@ -959,8 +988,8 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session,
old = chunk->uri;
chunk->uri = NULL;
- WT_ERR(__wt_lsm_tree_chunk_name(
- session, lsm_tree, chunk->id, &chunk->uri));
+ WT_ERR(__wt_lsm_tree_chunk_name(session, lsm_tree,
+ chunk->id, chunk->generation, &chunk->uri));
WT_ERR(__wt_schema_rename(session, old, chunk->uri, cfg));
__wt_free(session, old);