diff options
author | Don Anderson <dda@mongodb.com> | 2015-09-13 21:29:14 -0400 |
---|---|---|
committer | Don Anderson <dda@mongodb.com> | 2015-09-13 21:29:14 -0400 |
commit | 4c663725867d2f9434298d30883c58a0d96deaa9 (patch) | |
tree | 616aadaf780bdecd451acfcdb2148bc0d3640f99 | |
parent | 8e4bdd38f1800d6e6c62f5060b7d25e9d509d735 (diff) | |
parent | d44d75aa725ed485c64cd858cc8cdb4bdd494b1d (diff) | |
download | mongo-4c663725867d2f9434298d30883c58a0d96deaa9.tar.gz |
Merge pull request #2150 from wiredtiger/lsm-bulk-unordered
WT-147 Add undocumented bulk=unordered for LSM cursors.
-rw-r--r-- | dist/s_string.ok | 2 | ||||
-rw-r--r-- | src/cursor/cur_file.c | 18 | ||||
-rw-r--r-- | src/lsm/lsm_cursor_bulk.c | 18 |
3 files changed, 25 insertions, 13 deletions
diff --git a/dist/s_string.ok b/dist/s_string.ok index db33d89bab1..48c0f7f30f4 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -295,6 +295,7 @@ UnixLib Unmap UnmapViewOfFile Unmarshall +Unordered Uryyb VARCHAR VLDB @@ -949,6 +950,7 @@ unmarshall unmarshalled unmerged unmodify +unordered unpackv unpadded unreferenced diff --git a/src/cursor/cur_file.c b/src/cursor/cur_file.c index a9f3124149e..d30a2a04c22 100644 --- a/src/cursor/cur_file.c +++ b/src/cursor/cur_file.c @@ -487,6 +487,7 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, int bitmap, bulk; uint32_t flags; + bitmap = bulk = 0; flags = 0; WT_RET(__wt_config_gets_def(session, cfg, "bulk", 0, &cval)); @@ -497,6 +498,15 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, bulk = (cval.val != 0); } else if (WT_STRING_MATCH("bitmap", cval.str, cval.len)) bitmap = bulk = 1; + else if (WT_STRING_MATCH("unordered", cval.str, cval.len)) + /* + * Unordered bulk insert is a special case used internally by + * index creation on existing tables. It requires exclusive + * access, but not the other bulk semantics. It primarily + * exists to avoid some locking problems with LSM trees and + * index creation. + */ + LF_SET(WT_DHANDLE_EXCLUSIVE); else WT_RET_MSG(session, EINVAL, "Value for 'bulk' must be a boolean or 'bitmap'"); @@ -508,11 +518,11 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, /* Get the handle and lock it while the cursor is using it. */ if (WT_PREFIX_MATCH(uri, "file:")) { /* - * If we are opening a bulk cursor, get the handle while - * holding the checkpoint lock. This prevents a bulk cursor - * open failing with EBUSY due to a database-wide checkpoint. + * If we are opening exclusive, get the handle while holding + * the checkpoint lock. This prevents a bulk cursor open + * failing with EBUSY due to a database-wide checkpoint. */ - if (bulk) + if (LF_ISSET(WT_DHANDLE_EXCLUSIVE)) WT_WITH_CHECKPOINT_LOCK(session, ret = __wt_session_get_btree_ckpt( session, uri, cfg, flags)); diff --git a/src/lsm/lsm_cursor_bulk.c b/src/lsm/lsm_cursor_bulk.c index ef1c124111f..65e8fe1e9a7 100644 --- a/src/lsm/lsm_cursor_bulk.c +++ b/src/lsm/lsm_cursor_bulk.c @@ -91,6 +91,7 @@ int __wt_clsm_open_bulk(WT_CURSOR_LSM *clsm, const char *cfg[]) { WT_CURSOR *cursor, *bulk_cursor; + WT_DECL_RET; WT_LSM_TREE *lsm_tree; WT_SESSION_IMPL *session; @@ -106,17 +107,16 @@ __wt_clsm_open_bulk(WT_CURSOR_LSM *clsm, const char *cfg[]) cursor->insert = __clsm_insert_bulk; cursor->close = __clsm_close_bulk; - /* Setup the first chunk in the tree. */ - WT_RET(__wt_clsm_request_switch(clsm)); - WT_RET(__wt_clsm_await_switch(clsm)); - /* - * Grab and release the LSM tree lock to ensure that the first chunk - * has been fully created before proceeding. We have the LSM tree - * open exclusive, so that saves us from needing the lock generally. + * Setup the first chunk in the tree. This is the only time we switch + * without using the LSM worker threads, it's safe to do here since + * we have an exclusive lock on the LSM tree. We need to do this + * switch inline, since switch needs a schema lock and online index + * creation opens a bulk cursor while holding the schema lock. */ - WT_RET(__wt_lsm_tree_readlock(session, lsm_tree)); - WT_RET(__wt_lsm_tree_readunlock(session, lsm_tree)); + WT_WITH_SCHEMA_LOCK(session, + ret = __wt_lsm_tree_switch(session, lsm_tree)); + WT_RET(ret); /* * Open a bulk cursor on the first chunk, it's not a regular LSM chunk |