summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSulabh Mahajan <sulabh.mahajan@mongodb.com>2016-07-27 06:27:18 +1000
committersueloverso <sue@mongodb.com>2016-07-26 16:27:18 -0400
commite892427f099623146e0a5343d95ceb6dbb082d0f (patch)
tree0f8d5ae11ef5bfb5fe85f770880a8552af6ea8c4
parent6aaa39897a63423e4f048a169394d0bb59b8d063 (diff)
downloadmongo-e892427f099623146e0a5343d95ceb6dbb082d0f.tar.gz
WT-2781 Don't take checkpoint lock if checkpoint_wait=0 for bulk cursor open (#2897)
WT-2781 Add checkpoint_wait configuration for bulk cursor open API.
-rw-r--r--dist/api_data.py10
-rw-r--r--src/config/config_def.c7
-rw-r--r--src/cursor/cur_file.c17
-rw-r--r--src/session/session_api.c4
4 files changed, 26 insertions, 12 deletions
diff --git a/dist/api_data.py b/dist/api_data.py
index decd0fa95a4..e1b877a1a35 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -820,8 +820,9 @@ methods = {
'WT_SESSION.drop' : Method([
Config('checkpoint_wait', 'true', r'''
- wait for the checkpoint lock, if \c checkpoint_wait=false, fail if
- this lock is not available immediately''',
+ wait for the checkpoint lock, if \c checkpoint_wait=false, perform
+ the drop operation without taking a lock, returning EBUSY if the
+ operation conflicts with a running checkpoint''',
type='boolean', undoc=True),
Config('force', 'false', r'''
return success if the object does not exist''',
@@ -902,6 +903,11 @@ methods = {
"WiredTigerCheckpoint" opens the most recent internal
checkpoint taken for the object). The cursor does not
support data modification'''),
+ Config('checkpoint_wait', 'true', r'''
+ wait for the checkpoint lock, if \c checkpoint_wait=false, open the
+ cursor without taking a lock, returning EBUSY if the operation
+ conflicts with a running checkpoint''',
+ type='boolean', undoc=True),
Config('dump', '', r'''
configure the cursor for dump format inputs and outputs: "hex"
selects a simple hexadecimal format, "json" selects a JSON format
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 4a090975935..3a53256c5e2 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -317,6 +317,7 @@ static const WT_CONFIG_CHECK confchk_WT_SESSION_open_cursor[] = {
{ "append", "boolean", NULL, NULL, NULL, 0 },
{ "bulk", "string", NULL, NULL, NULL, 0 },
{ "checkpoint", "string", NULL, NULL, NULL, 0 },
+ { "checkpoint_wait", "boolean", NULL, NULL, NULL, 0 },
{ "dump", "string",
NULL, "choices=[\"hex\",\"json\",\"print\"]",
NULL, 0 },
@@ -1066,10 +1067,10 @@ static const WT_CONFIG_ENTRY config_entries[] = {
NULL, 0
},
{ "WT_SESSION.open_cursor",
- "append=0,bulk=0,checkpoint=,dump=,next_random=0,"
- "next_random_sample_size=0,overwrite=,raw=0,readonly=0,"
+ "append=0,bulk=0,checkpoint=,checkpoint_wait=,dump=,next_random=0"
+ ",next_random_sample_size=0,overwrite=,raw=0,readonly=0,"
"skip_sort_check=0,statistics=,target=",
- confchk_WT_SESSION_open_cursor, 12
+ confchk_WT_SESSION_open_cursor, 13
},
{ "WT_SESSION.rebalance",
"",
diff --git a/src/cursor/cur_file.c b/src/cursor/cur_file.c
index 94cd05e54ac..8e7bd4bbea5 100644
--- a/src/cursor/cur_file.c
+++ b/src/cursor/cur_file.c
@@ -510,9 +510,10 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri,
WT_CONFIG_ITEM cval;
WT_DECL_RET;
uint32_t flags;
- bool bitmap, bulk;
+ bool bitmap, bulk, checkpoint_wait;
bitmap = bulk = false;
+ checkpoint_wait = true;
flags = 0;
/*
@@ -538,6 +539,12 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri,
else if (!WT_STRING_MATCH("unordered", cval.str, cval.len))
WT_RET_MSG(session, EINVAL,
"Value for 'bulk' must be a boolean or 'bitmap'");
+
+ if (bulk) {
+ WT_RET(__wt_config_gets(session,
+ cfg, "checkpoint_wait", &cval));
+ checkpoint_wait = cval.val != 0;
+ }
}
/* Bulk handles require exclusive access. */
@@ -547,11 +554,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 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 we are opening exclusive and don't want a bulk cursor
+ * open to fail with EBUSY due to a database-wide checkpoint,
+ * get the handle while holding the checkpoint lock.
*/
- if (LF_ISSET(WT_DHANDLE_EXCLUSIVE))
+ if (LF_ISSET(WT_DHANDLE_EXCLUSIVE) && checkpoint_wait)
WT_WITH_CHECKPOINT_LOCK(session, ret,
ret = __wt_session_get_btree_ckpt(
session, uri, cfg, flags));
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 77d1dc74c84..253a5b7a147 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -733,8 +733,8 @@ __wt_session_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
F_SET(session, WT_SESSION_LOCK_NO_WAIT);
/*
- * The checkpoint lock only is needed to avoid a spurious EBUSY error
- * return.
+ * Take the checkpoint lock if there is a need to prevent the drop
+ * operation from failing with EBUSY due to an ongoing checkpoint.
*/
if (checkpoint_wait)
WT_WITH_CHECKPOINT_LOCK(session, ret,