Skip to content

Commit

Permalink
Import wiredtiger: ad25980c88b87d45dbcefdb10cdcf696d02a8ac2 from bran…
Browse files Browse the repository at this point in the history
…ch mongodb-3.8

ref: 5fc85c47ca..ad25980c88
for: 3.7.6

WT-3998       Fix a bug where stable timestamp was ignored on shutdown
WT-4012       Fix lookaside entry counters
WT-4019       Change test/format to test transaction prepare less often
WT-4027       Yield cursor operations between restarted search/traverse
WT-4031       on-page zero-length row-store values can be discarded from checkpoints
WT-4035       Truncate information discarded while active
WT-4036       Fix Coverity false positive: out-of-bounds access.
WT-4042       Access data handles safely during cursor reopen
  • Loading branch information
lukech committed Apr 18, 2018
1 parent f1dce2d commit 0ea8eba
Show file tree
Hide file tree
Showing 19 changed files with 319 additions and 182 deletions.
2 changes: 1 addition & 1 deletion src/third_party/wiredtiger/import.data
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commit": "5fc85c47caba5dbd4fc49ad6fa924fee4e3d5695",
"commit": "ad25980c88b87d45dbcefdb10cdcf696d02a8ac2",
"github": "wiredtiger/wiredtiger.git",
"vendor": "wiredtiger",
"branch": "mongodb-3.8"
Expand Down
46 changes: 34 additions & 12 deletions src/third_party/wiredtiger/src/btree/bt_cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,20 @@ __cursor_row_modify(
&cbt->iface.key, &cbt->iface.value, NULL, modify_type, false));
}

/*
* __cursor_restart --
* Common cursor restart handling.
*/
static void
__cursor_restart(
WT_SESSION_IMPL *session, uint64_t *yield_count, uint64_t *sleep_count)
{
__wt_state_yield_sleep(yield_count, sleep_count);

WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
}

/*
* __wt_btcur_reset --
* Invalidate the cursor position.
Expand Down Expand Up @@ -719,11 +733,13 @@ __wt_btcur_insert(WT_CURSOR_BTREE *cbt)
WT_CURSOR *cursor;
WT_DECL_RET;
WT_SESSION_IMPL *session;
uint64_t yield_count, sleep_count;
bool append_key, valid;

btree = cbt->btree;
cursor = &cbt->iface;
session = (WT_SESSION_IMPL *)cursor->session;
yield_count = sleep_count = 0;

WT_STAT_CONN_INCR(session, cursor_insert);
WT_STAT_DATA_INCR(session, cursor_insert);
Expand Down Expand Up @@ -840,8 +856,7 @@ retry: WT_ERR(__cursor_func_init(cbt, true));
}

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand Down Expand Up @@ -904,10 +919,12 @@ __wt_btcur_insert_check(WT_CURSOR_BTREE *cbt)
WT_CURSOR *cursor;
WT_DECL_RET;
WT_SESSION_IMPL *session;
uint64_t yield_count, sleep_count;

cursor = &cbt->iface;
btree = cbt->btree;
session = (WT_SESSION_IMPL *)cursor->session;
yield_count = sleep_count = 0;

/*
* The pinned page goes away if we do a search, get a local copy of any
Expand All @@ -929,8 +946,7 @@ retry: WT_ERR(__cursor_func_init(cbt, true));
WT_ERR(__wt_illegal_value(session, NULL));

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand All @@ -955,11 +971,13 @@ __wt_btcur_remove(WT_CURSOR_BTREE *cbt)
WT_CURSOR *cursor;
WT_DECL_RET;
WT_SESSION_IMPL *session;
uint64_t yield_count, sleep_count;
bool iterating, valid;

btree = cbt->btree;
cursor = &cbt->iface;
session = (WT_SESSION_IMPL *)cursor->session;
yield_count = sleep_count = 0;
iterating = F_ISSET(cbt, WT_CBT_ITERATE_NEXT | WT_CBT_ITERATE_PREV);

WT_STAT_CONN_INCR(session, cursor_remove);
Expand Down Expand Up @@ -1092,8 +1110,7 @@ retry: if (positioned == POSITIONED)
}

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand Down Expand Up @@ -1172,11 +1189,13 @@ __btcur_update(WT_CURSOR_BTREE *cbt, WT_ITEM *value, u_int modify_type)
WT_CURSOR *cursor;
WT_DECL_RET;
WT_SESSION_IMPL *session;
uint64_t yield_count, sleep_count;
bool valid;

btree = cbt->btree;
cursor = &cbt->iface;
session = (WT_SESSION_IMPL *)cursor->session;
yield_count = sleep_count = 0;

/* It's no longer possible to bulk-load into the tree. */
__cursor_disable_bulk(session, btree);
Expand Down Expand Up @@ -1268,8 +1287,7 @@ retry: WT_ERR(__cursor_func_init(cbt, true));
}

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand Down Expand Up @@ -1608,6 +1626,9 @@ __cursor_truncate(WT_SESSION_IMPL *session,
int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, u_int))
{
WT_DECL_RET;
uint64_t yield_count, sleep_count;

yield_count = sleep_count = 0;

/*
* First, call the cursor search method to re-position the cursor: we
Expand Down Expand Up @@ -1644,8 +1665,7 @@ retry: WT_ERR(__wt_btcur_search(start));
}

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand All @@ -1663,8 +1683,11 @@ __cursor_truncate_fix(WT_SESSION_IMPL *session,
int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, u_int))
{
WT_DECL_RET;
uint64_t yield_count, sleep_count;
const uint8_t *value;

yield_count = sleep_count = 0;

/*
* Handle fixed-length column-store objects separately: for row-store
* and variable-length column-store objects we have "deleted" values
Expand Down Expand Up @@ -1702,8 +1725,7 @@ retry: WT_ERR(__wt_btcur_search(start));
}

err: if (ret == WT_RESTART) {
WT_STAT_CONN_INCR(session, cursor_restart);
WT_STAT_DATA_INCR(session, cursor_restart);
__cursor_restart(session, &yield_count, &sleep_count);
goto retry;
}

Expand Down
22 changes: 10 additions & 12 deletions src/third_party/wiredtiger/src/btree/bt_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ __las_page_instantiate_verbose(WT_SESSION_IMPL *session, uint64_t las_pageid)
* Instantiate lookaside update records in a recently read page.
*/
static int
__las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t btree_id)
__las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref)
{
WT_CACHE *cache;
WT_CURSOR *cursor;
Expand All @@ -136,11 +136,12 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t btree_id)
locked = false;
total_incr = 0;
current_recno = recno = WT_RECNO_OOB;
las_pageid = ref->page_las->las_pageid;
session_flags = 0; /* [-Werror=maybe-uninitialized] */
WT_CLEAR(las_key);

cache = S2C(session)->cache;
__las_page_instantiate_verbose(session, ref->page_las->las_pageid);
__las_page_instantiate_verbose(session, las_pageid);
WT_STAT_CONN_INCR(session, cache_read_lookaside);
WT_STAT_DATA_INCR(session, cache_read_lookaside);

Expand All @@ -159,20 +160,19 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t btree_id)
* for a key and then insert those updates into the page, then all the
* updates for the next key, and so on.
*/
ret = __wt_las_cursor_position(
cursor, btree_id, ref->page_las->las_pageid);
__wt_readlock(session, &cache->las_sweepwalk_lock);
locked = true;
for (; ret == 0; ret = cursor->next(cursor)) {
for (ret = __wt_las_cursor_position(cursor, las_pageid);
ret == 0;
ret = cursor->next(cursor)) {
WT_ERR(cursor->get_key(cursor,
&las_pageid, &las_id, &las_counter, &las_key));

/*
* Confirm the search using the unique prefix; if not a match,
* we're done searching for records for this page.
*/
if (las_id != btree_id ||
las_pageid != ref->page_las->las_pageid)
if (las_pageid != ref->page_las->las_pageid)
break;

/* Allocate the WT_UPDATE structure. */
Expand Down Expand Up @@ -367,7 +367,6 @@ __evict_force_check(WT_SESSION_IMPL *session, WT_REF *ref)
static int
__page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
{
WT_BTREE *btree;
WT_DECL_RET;
WT_ITEM tmp;
WT_PAGE *notused;
Expand All @@ -377,7 +376,6 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
const uint8_t *addr;
bool timer;

btree = S2BT(session);
time_start = time_stop = 0;

/*
Expand Down Expand Up @@ -483,7 +481,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
* then apply the delete.
*/
if (ref->page_las != NULL) {
WT_ERR(__las_page_instantiate(session, ref, btree->id));
WT_ERR(__las_page_instantiate(session, ref));
ref->page_las->eviction_to_lookaside = false;
}

Expand All @@ -504,7 +502,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
if (previous_state == WT_REF_LIMBO)
WT_STAT_CONN_INCR(session, cache_read_lookaside_delay);

WT_ERR(__las_page_instantiate(session, ref, btree->id));
WT_ERR(__las_page_instantiate(session, ref));
ref->page_las->eviction_to_lookaside = false;
break;
}
Expand All @@ -518,7 +516,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
*/
if (final_state == WT_REF_MEM && ref->page_las != NULL)
WT_IGNORE_RET(__wt_las_remove_block(
session, btree->id, ref->page_las->las_pageid));
session, ref->page_las->las_pageid, false));

WT_PUBLISH(ref->state, final_state);
return (ret);
Expand Down
Loading

0 comments on commit 0ea8eba

Please sign in to comment.