Skip to content

Commit

Permalink
Merge branch 'develop' into mongodb-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cahill committed Feb 24, 2015
2 parents fc15500 + 66d4c37 commit 2ad51c2
Show file tree
Hide file tree
Showing 41 changed files with 216 additions and 2,520 deletions.
7 changes: 4 additions & 3 deletions src/btree/bt_compact.c
Expand Up @@ -76,7 +76,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_REF *ref;
int block_manager_begin, skip;
int block_manager_begin, evict_reset, skip;

WT_UNUSED(cfg);

Expand Down Expand Up @@ -133,8 +133,9 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
* then let eviction continue;
*/
conn->compact_in_memory_pass = 1;
WT_ERR(__wt_evict_file_exclusive_on(session));
__wt_evict_file_exclusive_off(session);
WT_ERR(__wt_evict_file_exclusive_on(session, &evict_reset));
if (evict_reset)
__wt_evict_file_exclusive_off(session);

/* Start compaction. */
WT_ERR(bm->compact_start(bm, session));
Expand Down
124 changes: 49 additions & 75 deletions src/btree/bt_cursor.c
Expand Up @@ -936,36 +936,22 @@ __cursor_truncate(WT_SESSION_IMPL *session,
* instantiated the end cursor, so we know that page is pinned in memory
* and we can proceed without concern.
*/
if (start == NULL) {
do {
WT_RET(__wt_btcur_remove(stop));
for (;;) {
if ((ret = __wt_btcur_prev(stop, 1)) != 0)
break;
stop->compare = 0; /* Exact match */
if ((ret = rmfunc(session, stop, 1)) != 0)
break;
}
} while (ret == WT_RESTART);
} else {
do {
WT_RET(__wt_btcur_remove(start));
/*
* Reset ret each time through so that we don't loop
* forever in the cursor equals case.
*/
for (ret = 0;;) {
if (stop != NULL &&
__cursor_equals(start, stop))
break;
if ((ret = __wt_btcur_next(start, 1)) != 0)
break;
start->compare = 0; /* Exact match */
if ((ret = rmfunc(session, start, 1)) != 0)
break;
}
} while (ret == WT_RESTART);
}
do {
WT_RET(__wt_btcur_remove(start));
/*
* Reset ret each time through so that we don't loop forever in
* the cursor equals case.
*/
for (ret = 0;;) {
if (stop != NULL && __cursor_equals(start, stop))
break;
if ((ret = __wt_btcur_next(start, 1)) != 0)
break;
start->compare = 0; /* Exact match */
if ((ret = rmfunc(session, start, 1)) != 0)
break;
}
} while (ret == WT_RESTART);

WT_RET_NOTFOUND_OK(ret);
return (0);
Expand Down Expand Up @@ -999,40 +985,24 @@ __cursor_truncate_fix(WT_SESSION_IMPL *session,
* other thread of control; in that case, repeat the full search to
* refresh the page's modification information.
*/
if (start == NULL) {
do {
WT_RET(__wt_btcur_remove(stop));
for (;;) {
if ((ret = __wt_btcur_prev(stop, 1)) != 0)
break;
stop->compare = 0; /* Exact match */
value = (uint8_t *)stop->iface.value.data;
if (*value != 0 &&
(ret = rmfunc(session, stop, 1)) != 0)
break;
}
} while (ret == WT_RESTART);
} else {
do {
WT_RET(__wt_btcur_remove(start));
/*
* Reset ret each time through so that we don't loop
* forever in the cursor equals case.
*/
for (ret = 0;;) {
if (stop != NULL &&
__cursor_equals(start, stop))
break;
if ((ret = __wt_btcur_next(start, 1)) != 0)
break;
start->compare = 0; /* Exact match */
value = (uint8_t *)start->iface.value.data;
if (*value != 0 &&
(ret = rmfunc(session, start, 1)) != 0)
break;
}
} while (ret == WT_RESTART);
}
do {
WT_RET(__wt_btcur_remove(start));
/*
* Reset ret each time through so that we don't loop forever in
* the cursor equals case.
*/
for (ret = 0;;) {
if (stop != NULL && __cursor_equals(start, stop))
break;
if ((ret = __wt_btcur_next(start, 1)) != 0)
break;
start->compare = 0; /* Exact match */
value = (uint8_t *)start->iface.value.data;
if (*value != 0 &&
(ret = rmfunc(session, start, 1)) != 0)
break;
}
} while (ret == WT_RESTART);

WT_RET_NOTFOUND_OK(ret);
return (0);
Expand All @@ -1055,9 +1025,15 @@ __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop)
btree = cbt->btree;

/*
* For recovery, we log the start and stop keys for a truncate
* operation, not the individual records removed. On the other hand,
* for rollback we need to keep track of all the in-memory operations.
* We always delete in a forward direction because it's faster, assert
* our caller provided us with a start cursor.
*/
WT_ASSERT(session, start != NULL);

/*
* For recovery, log the start and stop keys for a truncate operation,
* not the individual records removed. On the other hand, for rollback
* we need to keep track of all the in-memory operations.
*
* We deal with this here by logging the truncate range first, then (in
* the logging code) disabling writing of the in-memory remove records
Expand All @@ -1081,15 +1057,13 @@ __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop)
* fully instantiated when truncating row-store objects because
* it's comparing page and/or skiplist positions, not keys. (Key
* comparison would work, it's only that a key comparison would
* be relatively expensive. Column-store objects have record
* number keys, so the key comparison is cheap.) Cursors may
* have only had their keys set, so we must ensure the cursors
* are positioned in the tree.
* be relatively expensive, especially with custom collators.
* Column-store objects have record number keys, so the key
* comparison is cheap.) The session truncate code did cursor
* searches when setting up the truncate so we're good to go: if
* that ever changes, we'd need to do something here to ensure a
* fully instantiated cursor.
*/
if (start != NULL)
WT_ERR(__wt_btcur_search(start));
if (stop != NULL)
WT_ERR(__wt_btcur_search(stop));
WT_ERR(__cursor_truncate(
session, start, stop, __cursor_row_modify));
break;
Expand Down
17 changes: 13 additions & 4 deletions src/btree/bt_page.c
Expand Up @@ -129,15 +129,24 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags
__evict_force_check(session, page, flags)) {
++force_attempts;
ret = __wt_page_release_evict(session, ref);
/* If forced eviction fails, stall. */
if (ret == EBUSY) {
/* If forced eviction fails, stall. */
ret = 0;
wait_cnt += 1000;
WT_STAT_FAST_CONN_INCR(session,
page_forcible_evict_blocked);
break;
} else
WT_RET(ret);
WT_STAT_FAST_CONN_INCR(
session, page_forcible_evict_blocked);
break;

/*
* The result of a successful forced eviction
* is a page-state transition (potentially to
* an in-memory page we can use, or a restart
* return for our caller), continue the outer
* page-acquisition loop.
*/
continue;
}

/* Check if we need an autocommit transaction. */
Expand Down
7 changes: 4 additions & 3 deletions src/btree/bt_sync.c
Expand Up @@ -25,6 +25,7 @@ __sync_file(WT_SESSION_IMPL *session, int syncop)
uint64_t internal_bytes, leaf_bytes;
uint64_t internal_pages, leaf_pages;
uint32_t flags;
int evict_reset;

btree = S2BT(session);

Expand Down Expand Up @@ -99,11 +100,11 @@ __sync_file(WT_SESSION_IMPL *session, int syncop)
* eviction to complete.
*/
btree->checkpointing = 1;
WT_FULL_BARRIER();

if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) {
WT_ERR(__wt_evict_file_exclusive_on(session));
WT_ERR(__wt_evict_file_exclusive_on(session, &evict_reset));
if (evict_reset)
__wt_evict_file_exclusive_off(session);
}

/* Write all dirty in-cache pages. */
flags |= WT_READ_NO_EVICT;
Expand Down
21 changes: 9 additions & 12 deletions src/conn/conn_dhandle.c
Expand Up @@ -475,16 +475,15 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle,
WT_DECL_RET;

/*
* We need to pull the handle into the session handle
* cache and make sure it's referenced to stop other
* internal code dropping the handle (e.g in LSM when
* cleaning up obsolete chunks). Holding the metadata
* lock isn't enough.
* We need to pull the handle into the session handle cache and make
* sure it's referenced to stop other internal code dropping the handle
* (e.g in LSM when cleaning up obsolete chunks).
*/
ret = __wt_session_get_btree(session,
dhandle->name, dhandle->checkpoint, NULL, 0);
if (ret == 0) {
ret = func(session, cfg);
WT_SAVE_DHANDLE(session,
ret = func(session, cfg));
if (WT_META_TRACKING(session))
WT_TRET(__wt_meta_track_handle_lock(session, 0));
else
Expand Down Expand Up @@ -550,12 +549,11 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session,
int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[])
{
WT_CONNECTION_IMPL *conn;
WT_DATA_HANDLE *dhandle, *saved_dhandle;
WT_DATA_HANDLE *dhandle;
WT_DECL_RET;
uint64_t bucket, hash;

conn = S2C(session);
saved_dhandle = session->dhandle;

WT_ASSERT(session, F_ISSET(session, WT_SESSION_HANDLE_LIST_LOCKED));

Expand All @@ -578,15 +576,14 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session,
*/
__wt_spin_lock(session, &dhandle->close_lock);
if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) {
session->dhandle = dhandle;
ret = func(session, cfg);
WT_WITH_DHANDLE(session, dhandle,
ret = func(session, cfg));
}
__wt_spin_unlock(session, &dhandle->close_lock);
WT_ERR(ret);
}

err: session->dhandle = saved_dhandle;
return (ret);
err: return (ret);
}

/*
Expand Down
8 changes: 6 additions & 2 deletions src/conn/conn_stat.c
Expand Up @@ -193,6 +193,7 @@ static int
__statlog_apply(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_DATA_HANDLE *dhandle;
WT_DECL_RET;
char **p;

WT_UNUSED(cfg);
Expand All @@ -201,8 +202,11 @@ __statlog_apply(WT_SESSION_IMPL *session, const char *cfg[])

/* Check for a match on the set of sources. */
for (p = S2C(session)->stat_sources; *p != NULL; ++p)
if (WT_PREFIX_MATCH(dhandle->name, *p))
return (__statlog_dump(session, dhandle->name, 0));
if (WT_PREFIX_MATCH(dhandle->name, *p)) {
WT_WITHOUT_DHANDLE(session,
ret = __statlog_dump(session, dhandle->name, 0));
WT_RET(ret);
}
return (0);
}

Expand Down
11 changes: 3 additions & 8 deletions src/evict/evict_file.c
Expand Up @@ -15,21 +15,16 @@
int
__wt_evict_file(WT_SESSION_IMPL *session, int syncop)
{
WT_BTREE *btree;
WT_DECL_RET;
WT_PAGE *page;
WT_REF *next_ref, *ref;
int eviction_enabled;

btree = S2BT(session);
eviction_enabled = !F_ISSET(btree, WT_BTREE_NO_EVICTION);
int evict_reset;

/*
* We need exclusive access to the file -- disable ordinary eviction
* and drain any blocks already queued.
*/
if (eviction_enabled)
WT_RET(__wt_evict_file_exclusive_on(session));
WT_RET(__wt_evict_file_exclusive_on(session, &evict_reset));

/* Make sure the oldest transaction ID is up-to-date. */
__wt_txn_update_oldest(session);
Expand Down Expand Up @@ -140,7 +135,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop)
session, next_ref, WT_READ_NO_EVICT));
}

if (eviction_enabled)
if (evict_reset)
__wt_evict_file_exclusive_off(session);

return (ret);
Expand Down

0 comments on commit 2ad51c2

Please sign in to comment.