Skip to content

Commit

Permalink
WT-2781 Don't take checkpoint lock if checkpoint_wait=0 for bulk curs…
Browse files Browse the repository at this point in the history
…or open (#2897)

WT-2781 Add checkpoint_wait configuration for bulk cursor open API.
  • Loading branch information
sulabhM authored and sueloverso committed Jul 26, 2016
1 parent 6aaa398 commit e892427
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
10 changes: 8 additions & 2 deletions dist/api_data.py
Expand Up @@ -820,8 +820,9 @@ def __cmp__(self, other):

'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''',
Expand Down Expand Up @@ -902,6 +903,11 @@ def __cmp__(self, other):
"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
Expand Down
7 changes: 4 additions & 3 deletions src/config/config_def.c
Expand Up @@ -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 },
Expand Down Expand Up @@ -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",
"",
Expand Down
17 changes: 12 additions & 5 deletions src/cursor/cur_file.c
Expand Up @@ -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;

/*
Expand All @@ -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. */
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/session/session_api.c
Expand Up @@ -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,
Expand Down

0 comments on commit e892427

Please sign in to comment.