diff options
author | Luke Chen <luke.chen@mongodb.com> | 2018-03-27 10:29:16 +1100 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2018-03-27 10:29:16 +1100 |
commit | e93e3e7930f844bf830715dfecbb602eefe48b8e (patch) | |
tree | df168729a1b9906fb1f0f03fe0352ad5c39c84d0 /src/third_party | |
parent | 152885358a4ecab312c690b2ffee5dfb7c37311a (diff) | |
download | mongo-e93e3e7930f844bf830715dfecbb602eefe48b8e.tar.gz |
Import wiredtiger: 875e91581c63e1e4d47c547291f0a582f30eddae from branch mongodb-3.8
ref: cce16aa64e..875e91581c
for: 3.7.4
WT-3869 Bi-weekly WT codebase lint
WT-3979 Fix warnings generated with newer Doxygen releases
WT-3982 Fix transaction visibility bugs related to lookaside usage.
WT-3985 Pre-allocated log files accumulate on Windows
WT-3987 Avoid reading lookaside pages in truncate fast path
WT-3990 Fix Coverity tickets
Diffstat (limited to 'src/third_party')
39 files changed, 499 insertions, 311 deletions
diff --git a/src/third_party/wiredtiger/dist/s_prototypes b/src/third_party/wiredtiger/dist/s_prototypes index 20e08eb4c54..75863cf8f87 100755 --- a/src/third_party/wiredtiger/dist/s_prototypes +++ b/src/third_party/wiredtiger/dist/s_prototypes @@ -42,7 +42,8 @@ proto() -e x \ -e '}' \ -e '# Add the warn_unused_result attribute to any external' \ - -e '# functions that return an int.' \ + -e '# functions that return a boolean or an int.' \ + -e '/^extern bool /s/$/ WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result))/' \ -e '/^extern int /s/$/ WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result))/' \ -e 's/$/;/' \ -e p < $1 diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index aa68e584376..7330f560eb6 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -138,6 +138,7 @@ FULLFSYNC Facebook FindClose FindFirstFile +FindNextFileW Fixup Fk FlushFileBuffers @@ -523,7 +524,7 @@ ccr cd centric cfg -cfkos +cfko change's changelog chdir diff --git a/src/third_party/wiredtiger/ext/test/fail_fs/fail_fs.c b/src/third_party/wiredtiger/ext/test/fail_fs/fail_fs.c index bde1bfc48bf..bdb4669a637 100644 --- a/src/third_party/wiredtiger/ext/test/fail_fs/fail_fs.c +++ b/src/third_party/wiredtiger/ext/test/fail_fs/fail_fs.c @@ -452,16 +452,14 @@ fail_fs_directory_list(WT_FILE_SYSTEM *file_system, * matter if the list is a bit longer than necessary. */ if (count >= allocated) { - p = realloc( - entries, (allocated + 10) * sizeof(*entries)); - if (p == NULL) { + allocated += 10; + if ((p = realloc( + entries, allocated * sizeof(*entries))) == NULL) { ret = ENOMEM; goto err; } entries = p; - memset(entries + allocated * sizeof(*entries), - 0, 10 * sizeof(*entries)); - allocated += 10; + memset(entries + count, 0, 10 * sizeof(*entries)); } entries[count++] = strdup(name); } diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index be1290048f0..699ff2083f7 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -1,5 +1,5 @@ { - "commit": "cce16aa64e85274253a01be778734bff8d6bba06", + "commit": "875e91581c63e1e4d47c547291f0a582f30eddae", "github": "wiredtiger/wiredtiger.git", "vendor": "wiredtiger", "branch": "mongodb-3.8" diff --git a/src/third_party/wiredtiger/src/block/block_open.c b/src/third_party/wiredtiger/src/block/block_open.c index 7c7e0e5c525..32e13acfa83 100644 --- a/src/third_party/wiredtiger/src/block/block_open.c +++ b/src/third_party/wiredtiger/src/block/block_open.c @@ -256,7 +256,7 @@ __wt_block_close(WT_SESSION_IMPL *session, WT_BLOCK *block) conn = S2C(session); __wt_verbose(session, WT_VERB_BLOCK, - "close: %s", block->name == NULL ? "" : block->name ); + "close: %s", block->name == NULL ? "" : block->name); __wt_spin_lock(session, &conn->block_lock); diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c index bf535896c73..9a30ee2c1a4 100644 --- a/src/third_party/wiredtiger/src/btree/bt_cursor.c +++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c @@ -655,30 +655,43 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) exact = 0; F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); F_SET(cursor, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT); - } else if ((ret = __wt_btcur_next(cbt, false)) != WT_NOTFOUND) { - WT_ERR(ret); - exact = 1; } else { /* - * The cursor next call may have overwritten our caller's key, - * restore it to its original value. + * We didn't find an exact match: try after the search key, + * then before. We have to loop here because at low isolation + * levels, new records could appear as we are stepping through + * the tree. */ - __cursor_state_restore(cursor, &state); + while ((ret = __wt_btcur_next(cbt, false)) != WT_NOTFOUND) { + WT_ERR(ret); + if (btree->type == BTREE_ROW) + WT_ERR(__wt_compare(session, btree->collator, + &cursor->key, &state.key, &exact)); + else + exact = cbt->recno < state.recno ? -1 : + cbt->recno == state.recno ? 0 : 1; + if (exact >= 0) + goto done; + } - WT_ERR(__cursor_func_init(cbt, true)); - WT_ERR(btree->type == BTREE_ROW ? - __cursor_row_search(session, cbt, NULL, true) : - __cursor_col_search(session, cbt, NULL)); - WT_ERR(__wt_cursor_valid(cbt, &upd, &valid)); - if (valid) { - exact = cbt->compare; - ret = __cursor_kv_return(session, cbt, upd); - } else if ((ret = __wt_btcur_prev(cbt, false)) != WT_NOTFOUND) { + /* + * We walked to the end of the tree without finding a match. + * Walk backwards instead. + */ + while ((ret = __wt_btcur_prev(cbt, false)) != WT_NOTFOUND) { WT_ERR(ret); - exact = -1; + if (btree->type == BTREE_ROW) + WT_ERR(__wt_compare(session, btree->collator, + &cursor->key, &state.key, &exact)); + else + exact = cbt->recno < state.recno ? -1 : + cbt->recno == state.recno ? 0 : 1; + if (exact <= 0) + goto done; } } +done: err: if (ret == 0 && exactp != NULL) *exactp = exact; diff --git a/src/third_party/wiredtiger/src/btree/bt_delete.c b/src/third_party/wiredtiger/src/btree/bt_delete.c index e9ac0bca66a..cb50bfbcf61 100644 --- a/src/third_party/wiredtiger/src/btree/bt_delete.c +++ b/src/third_party/wiredtiger/src/btree/bt_delete.c @@ -65,17 +65,18 @@ int __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) { + WT_ADDR *ref_addr; WT_DECL_RET; - WT_PAGE *parent; uint32_t previous_state; *skipp = false; /* If we have a clean page in memory, attempt to evict it. */ - if (ref->state == WT_REF_MEM && - __wt_atomic_casv32(&ref->state, WT_REF_MEM, WT_REF_LOCKED)) { + previous_state = ref->state; + if ((previous_state == WT_REF_MEM || previous_state == WT_REF_LIMBO) && + __wt_atomic_casv32(&ref->state, previous_state, WT_REF_LOCKED)) { if (__wt_page_is_modified(ref->page)) { - ref->state = WT_REF_MEM; + ref->state = previous_state; return (0); } @@ -93,7 +94,6 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) previous_state = ref->state; switch (previous_state) { case WT_REF_DISK: - case WT_REF_LIMBO: case WT_REF_LOOKASIDE: break; default: @@ -101,21 +101,9 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) } if (!__wt_atomic_casv32(&ref->state, previous_state, WT_REF_LOCKED)) return (0); - switch (previous_state) { - case WT_REF_DISK: - break; - case WT_REF_LIMBO: - case WT_REF_LOOKASIDE: - if (__wt_las_page_skip_locked(session, ref)) - break; - /* FALLTHROUGH */ - default: - ref->state = previous_state; - return (0); - } /* - * If this WT_REF was previously part of a fast-delete operation, there + * If this WT_REF was previously part of a truncate operation, there * may be existing page-delete information. The structure is only read * while the state is locked, free the previous version. * @@ -129,21 +117,24 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) } /* - * We cannot fast-delete pages that have overflow key/value items as - * the overflow blocks have to be discarded. The way we figure that - * out is to check the page's cell type, cells for leaf pages without - * overflow items are special. + * We cannot truncate pages that have overflow key/value items as the + * overflow blocks have to be discarded. The way we figure that out is + * to check the page's cell type, cells for leaf pages without overflow + * items are special. * * To look at an on-page cell, we need to look at the parent page, and * that's dangerous, our parent page could change without warning if - * the parent page were to split, deepening the tree. It's safe: the - * page's reference will always point to some valid page, and if we find - * any problems we simply fail the fast-delete optimization. + * the parent page were to split, deepening the tree. We can look at + * the parent page itself because the page can't change underneath us. + * However, if the parent page splits, our reference address can change; + * we don't care what version of it we read, as long as we don't read + * it twice. */ - parent = ref->home; - if (__wt_off_page(parent, ref->addr) ? - ((WT_ADDR *)ref->addr)->type != WT_ADDR_LEAF_NO : - __wt_cell_type_raw(ref->addr) != WT_CELL_ADDR_LEAF_NO) + WT_ORDERED_READ(ref_addr, ref->addr); + if (ref_addr != NULL && + (__wt_off_page(ref->home, ref_addr) ? + ref_addr->type != WT_ADDR_LEAF_NO : + __wt_cell_type_raw((WT_CELL *)ref_addr) != WT_CELL_ADDR_LEAF_NO)) goto err; /* @@ -181,8 +172,10 @@ err: __wt_free(session, ref->page_del); int __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) { - WT_UPDATE **upd; + WT_UPDATE **updp; uint64_t sleep_count, yield_count; + uint32_t current_state; + bool locked; /* * If the page is still "deleted", it's as we left it, reset the state @@ -190,17 +183,17 @@ __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) * instantiated or being instantiated. Loop because it's possible for * the page to return to the deleted state if instantiation fails. */ - for (sleep_count = yield_count = 0;;) { - switch (ref->state) { + for (locked = false, sleep_count = yield_count = 0;;) { + switch (current_state = ref->state) { case WT_REF_DELETED: /* * If the page is still "deleted", it's as we left it, * reset the state. */ - if (!__wt_atomic_casv32(&ref->state, + if (__wt_atomic_casv32(&ref->state, WT_REF_DELETED, ref->page_del->previous_state)) - break; - goto done; + goto done; + break; case WT_REF_LOCKED: /* * A possible state, the page is being instantiated. @@ -208,22 +201,10 @@ __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) break; case WT_REF_MEM: case WT_REF_SPLIT: - /* - * We can't use the normal read path to get a copy of - * the page because the session may have closed the - * cursor, we no longer have the reference to the tree - * required for a hazard pointer. We're safe because - * with unresolved transactions, the page isn't going - * anywhere. - * - * The page is in an in-memory state, which means it - * was instantiated at some point. Walk the list of - * update structures and abort them. - */ - for (upd = - ref->page_del->update_list; *upd != NULL; ++upd) - (*upd)->txnid = WT_TXN_ABORTED; - goto done; + if (__wt_atomic_casv32( + &ref->state, current_state, WT_REF_LOCKED)) + locked = true; + break; case WT_REF_DISK: case WT_REF_LIMBO: case WT_REF_LOOKASIDE: @@ -232,16 +213,38 @@ __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) return (__wt_illegal_value(session, "illegal WT_REF.state rolling back deleted page")); } + + if (locked) + break; + /* * We wait for the change in page state, yield before retrying, - * and if we've yielded enough times, start sleeping so we don't - * burn CPU to no purpose. + * and if we've yielded enough times, start sleeping so we + * don't burn CPU to no purpose. */ __wt_ref_state_yield_sleep(&yield_count, &sleep_count); - WT_STAT_CONN_INCRV(session, page_del_rollback_blocked, - sleep_count); + WT_STAT_CONN_INCRV(session, + page_del_rollback_blocked, sleep_count); } + /* + * We can't use the normal read path to get a copy of the page + * because the session may have closed the cursor, we no longer + * have the reference to the tree required for a hazard + * pointer. We're safe because with unresolved transactions, + * the page isn't going anywhere. + * + * The page is in an in-memory state, which means it + * was instantiated at some point. Walk any list of + * update structures and abort them. + */ + WT_ASSERT(session, locked); + if ((updp = ref->page_del->update_list) != NULL) + for (; *updp != NULL; ++updp) + (*updp)->txnid = WT_TXN_ABORTED; + + ref->state = current_state; + done: /* * Now mark the truncate aborted: this must come last because after * this point there is nothing preventing the page from being evicted. @@ -261,12 +264,12 @@ __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) bool skip; /* - * Deleted pages come from two sources: either it's a fast-delete as + * Deleted pages come from two sources: either it's a truncate as * described above, or the page has been emptied by other operations * and eviction deleted it. * * In both cases, the WT_REF state will be WT_REF_DELETED. In the case - * of a fast-delete page, there will be a WT_PAGE_DELETED structure with + * of a truncated page, there will be a WT_PAGE_DELETED structure with * the transaction ID of the transaction that deleted the page, and the * page is visible if that transaction ID is visible. In the case of an * empty page, there will be no WT_PAGE_DELETED structure and the delete @@ -308,6 +311,31 @@ __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) } /* + * __tombstone_update_alloc -- + * Allocate and initialize a page-deleted tombstone update structure. + */ +static int +__tombstone_update_alloc(WT_SESSION_IMPL *session, + WT_PAGE_DELETED *page_del, WT_UPDATE **updp, size_t *sizep) +{ + WT_UPDATE *upd; + + WT_RET( + __wt_update_alloc(session, NULL, &upd, sizep, WT_UPDATE_TOMBSTONE)); + + /* + * Cleared memory matches the lowest possible transaction ID and + * timestamp, do nothing. + */ + if (page_del != NULL) { + upd->txnid = page_del->txnid; + __wt_timestamp_set(&upd->timestamp, &page_del->timestamp); + } + *updp = upd; + return (0); +} + +/* * __wt_delete_page_instantiate -- * Instantiate an entirely deleted row-store leaf page. */ @@ -316,11 +344,14 @@ __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) { WT_BTREE *btree; WT_DECL_RET; + WT_INSERT *ins; + WT_INSERT_HEAD *insert; WT_PAGE *page; WT_PAGE_DELETED *page_del; + WT_ROW *rip; WT_UPDATE **upd_array, *upd; size_t size; - uint32_t i; + uint32_t count, i; btree = S2BT(session); page = ref->page; @@ -355,52 +386,75 @@ __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) * running inside a checkpoint, and now we're being forced to read that * page. * - * In the first case, we have a page reference structure, in the second, - * we don't. - * - * Allocate the per-reference update array; in the case of instantiating - * a page, deleted by a running transaction that might eventually abort, - * we need a list of the update structures so we can do that abort. The - * hard case is if a page splits: the update structures might be moved - * to different pages, and we still have to find them all for an abort. + * Expect a page-deleted structure if there's a running transaction that + * needs to be resolved, otherwise, there may not be one (and, if the + * transaction has resolved, we can ignore the page-deleted structure). */ - page_del = ref->page_del; - if (page_del != NULL) - WT_RET(__wt_calloc_def( - session, page->entries + 1, &page_del->update_list)); + page_del = + __wt_btree_truncate_active(session, ref) ? ref->page_del : NULL; /* - * Allocate the per-page update array if one doesn't already exist. - * Because deletes may be instantiated after lookaside table updates, - * the update array may already exist. + * Allocate the per-page update array if one doesn't already exist. (It + * might already exist because deletes are instantiated after lookaside + * table updates.) */ - if (page->modify->mod_row_update == NULL) - WT_ERR(__wt_calloc_def( + if (page->entries != 0 && page->modify->mod_row_update == NULL) + WT_RET(__wt_calloc_def( session, page->entries, &page->modify->mod_row_update)); /* - * Fill in the per-reference update array with references to update - * structures, fill in the per-page update array with references to - * deleted items. + * Allocate the per-reference update array; in the case of instantiating + * a page deleted in a running transaction, we need a list of the update + * structures for the eventual commit or abort. */ - upd_array = page->modify->mod_row_update; - for (i = 0, size = 0; i < page->entries; ++i) { - WT_ERR(__wt_calloc_one(session, &upd)); - upd->type = WT_UPDATE_TOMBSTONE; - - if (page_del == NULL) - upd->txnid = WT_TXN_NONE; /* Globally visible */ - else { - upd->txnid = page_del->txnid; - __wt_timestamp_set( - &upd->timestamp, &page_del->timestamp); - page_del->update_list[i] = upd; + if (page_del != NULL) { + count = 0; + if ((insert = WT_ROW_INSERT_SMALLEST(page)) != NULL) + WT_SKIP_FOREACH(ins, insert) + ++count; + WT_ROW_FOREACH(page, rip, i) { + ++count; + if ((insert = WT_ROW_INSERT(page, rip)) != NULL) + WT_SKIP_FOREACH(ins, insert) + ++count; } + WT_RET(__wt_calloc_def( + session, count + 1, &page_del->update_list)); + } - upd->next = upd_array[i]; - upd_array[i] = upd; - - size += sizeof(WT_UPDATE *) + WT_UPDATE_MEMSIZE(upd); + /* Walk the page entries, giving each one a tombstone. */ + size = 0; + count = 0; + upd_array = page->modify->mod_row_update; + if ((insert = WT_ROW_INSERT_SMALLEST(page)) != NULL) + WT_SKIP_FOREACH(ins, insert) { + WT_ERR(__tombstone_update_alloc( + session, page_del, &upd, &size)); + upd->next = ins->upd; + ins->upd = upd; + + if (page_del != NULL) + page_del->update_list[count++] = upd; + } + WT_ROW_FOREACH(page, rip, i) { + WT_ERR(__tombstone_update_alloc( + session, page_del, &upd, &size)); + upd->next = upd_array[WT_ROW_SLOT(page, rip)]; + upd_array[WT_ROW_SLOT(page, rip)] = upd; + + if (page_del != NULL) + page_del->update_list[count++] = upd; + + if ((insert = WT_ROW_INSERT(page, rip)) != NULL) + WT_SKIP_FOREACH(ins, insert) { + WT_ERR(__tombstone_update_alloc( + session, page_del, &upd, &size)); + upd->next = ins->upd; + ins->upd = upd; + + if (page_del != NULL) + page_del->update_list[count++] = upd; + } } __wt_cache_page_inmem_incr(session, page, size); diff --git a/src/third_party/wiredtiger/src/btree/bt_io.c b/src/third_party/wiredtiger/src/btree/bt_io.c index 4c108114438..1379553c211 100644 --- a/src/third_party/wiredtiger/src/btree/bt_io.c +++ b/src/third_party/wiredtiger/src/btree/bt_io.c @@ -355,8 +355,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, * Checksum the data if the buffer isn't compressed or checksums are * configured. */ - data_checksum = true; /* -Werror=maybe-uninitialized */ - WT_NOT_READ(data_checksum); + WT_NOT_READ(data_checksum, true); switch (btree->checksum) { case CKSUM_ON: data_checksum = true; diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index 4ac0cb2da9b..450fd6cf563 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -370,7 +370,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) WT_BTREE *btree; WT_DECL_RET; WT_ITEM tmp; - WT_PAGE *page; + WT_PAGE *notused; size_t addr_size; uint64_t time_start, time_stop; uint32_t page_flags, final_state, new_state, previous_state; @@ -378,7 +378,6 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) bool timer; btree = S2BT(session); - page = NULL; time_start = time_stop = 0; /* @@ -427,11 +426,8 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) if (addr == NULL) { WT_ASSERT(session, previous_state != WT_REF_DISK); - WT_ERR(__wt_btree_new_leaf_page(session, &page)); - ref->page = page; - if (previous_state == WT_REF_LOOKASIDE) - goto skip_read; - goto done; + WT_ERR(__wt_btree_new_leaf_page(session, &ref->page)); + goto skip_read; } /* @@ -464,7 +460,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) WT_DATA_IN_ITEM(&tmp) ? WT_PAGE_DISK_ALLOC : WT_PAGE_DISK_MAPPED; if (LF_ISSET(WT_READ_IGNORE_CACHE_SIZE)) FLD_SET(page_flags, WT_PAGE_EVICT_NO_PROGRESS); - WT_ERR(__wt_page_inmem(session, ref, tmp.data, page_flags, &page)); + WT_ERR(__wt_page_inmem(session, ref, tmp.data, page_flags, ¬used)); tmp.mem = NULL; /* @@ -481,7 +477,7 @@ skip_read: switch (previous_state) { case WT_REF_DELETED: /* - * A fast-deleted page may also have lookaside information. The + * A truncated page may also have lookaside information. The * delete happened after page eviction (writing the lookaside * information), first update based on the lookaside table and * then apply the delete. @@ -491,6 +487,7 @@ skip_read: ref->page_las->eviction_to_lookaside = false; } + /* Move all records to a deleted state. */ WT_ERR(__wt_delete_page_instantiate(session, ref)); break; case WT_REF_LOOKASIDE: @@ -523,7 +520,7 @@ skip_read: WT_IGNORE_RET(__wt_las_remove_block( session, btree->id, ref->page_las->las_pageid)); -done: WT_PUBLISH(ref->state, final_state); + WT_PUBLISH(ref->state, final_state); return (ret); err: /* @@ -719,8 +716,7 @@ read: /* ret = __wt_page_release_evict(session, ref); /* If forced eviction fails, stall. */ if (ret == EBUSY) { - ret = 0; - WT_NOT_READ(ret); + WT_NOT_READ(ret, 0); WT_STAT_CONN_INCR(session, page_forcible_evict_blocked); stalled = true; diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index 36bbe48b407..3596f5a72b7 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -719,8 +719,7 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, alloc_refp - alloc_index->index == (ptrdiff_t)result_entries); /* Start making real changes to the tree, errors are fatal. */ - complete = WT_ERR_PANIC; - WT_NOT_READ(complete); + WT_NOT_READ(complete, WT_ERR_PANIC); /* Encourage a race */ __page_split_timing_stress(session, diff --git a/src/third_party/wiredtiger/src/btree/bt_walk.c b/src/third_party/wiredtiger/src/btree/bt_walk.c index 22921d7d378..535e804d6a8 100644 --- a/src/third_party/wiredtiger/src/btree/bt_walk.c +++ b/src/third_party/wiredtiger/src/btree/bt_walk.c @@ -517,8 +517,7 @@ restart: /* * in-cache pages, or if we see a deleted page. */ if (ret == WT_NOTFOUND) { - ret = 0; - WT_NOT_READ(ret); + WT_NOT_READ(ret, 0); break; } diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c index 569a0247e7b..7ccc325523e 100644 --- a/src/third_party/wiredtiger/src/cache/cache_las.c +++ b/src/third_party/wiredtiger/src/cache/cache_las.c @@ -993,7 +993,8 @@ __wt_las_sweep(WT_SESSION_IMPL *session) #else wt_timestamp_t *val_ts; #endif - uint64_t cnt, decrement_cnt, las_counter, las_pageid, txnid; + uint64_t cnt, decrement_cnt, las_counter, las_pageid, saved_pageid; + uint64_t las_txnid; uint32_t las_id, session_flags; uint8_t upd_type; int notused; @@ -1007,6 +1008,7 @@ __wt_las_sweep(WT_SESSION_IMPL *session) local_txn = locked = false; WT_RET(__wt_scr_alloc(session, 0, &saved_key)); + saved_pageid = 0; /* * Allocate a cursor and wrap all the updates in a transaction. @@ -1059,6 +1061,20 @@ __wt_las_sweep(WT_SESSION_IMPL *session) /* Walk the file. */ while ((ret = cursor->next(cursor)) == 0) { + WT_ERR(cursor->get_key(cursor, + &las_pageid, &las_id, &las_counter, &las_key)); + + /* + * If we have switched to a different page, clear the saved key. + * Otherwise, sweep could incorrectly remove records after + * seeing a birthmark for a key in one block if the same key is + * at the beginning of the next block. See WT-3982 for details. + */ + if (las_pageid != saved_pageid) { + saved_key->size = 0; + saved_pageid = las_pageid; + } + /* * Stop if the cache is stuck: we are ignoring the cache size * while scanning the lookaside table, so we're making things @@ -1076,9 +1092,6 @@ __wt_las_sweep(WT_SESSION_IMPL *session) else if (saved_key->size == 0) break; - WT_ERR(cursor->get_key(cursor, - &las_pageid, &las_id, &las_counter, &las_key)); - /* * If the entry belongs to a dropped tree, discard it. * @@ -1102,7 +1115,7 @@ __wt_las_sweep(WT_SESSION_IMPL *session) * now no longer needed. */ WT_ERR(cursor->get_value(cursor, - &txnid, &las_timestamp, &upd_type, &las_value)); + &las_txnid, &las_timestamp, &upd_type, &las_value)); #ifdef HAVE_TIMESTAMPS WT_ASSERT(session, las_timestamp.size == WT_TIMESTAMP_SIZE); memcpy(×tamp, las_timestamp.data, las_timestamp.size); @@ -1116,7 +1129,7 @@ __wt_las_sweep(WT_SESSION_IMPL *session) * If it is visible then perform additional checks to see * whether it has aged out of a live file. */ - if (!__wt_txn_visible_all(session, txnid, val_ts)) { + if (!__wt_txn_visible_all(session, las_txnid, val_ts)) { saved_key->size = 0; continue; } diff --git a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c index 720df3c465d..f1043ee7546 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c @@ -303,8 +303,8 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) conn = S2C(session); cache = conn->cache; - cp_locked = found = false; - WT_NOT_READ(cp_locked); + WT_NOT_READ(cp_locked, false); + found = false; cp = __wt_process.cache_pool; if (!F_ISSET(conn, WT_CONN_CACHE_POOL)) @@ -338,8 +338,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * operation. */ __wt_spin_unlock(session, &cp->cache_pool_lock); - cp_locked = false; - WT_NOT_READ(cp_locked); + WT_NOT_READ(cp_locked, false); FLD_CLR(cache->pool_flags, WT_CACHE_POOL_RUN); __wt_cond_signal(session, cp->cache_pool_cond); diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index 6e27d0f98d6..fed45dbf4c4 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -598,8 +598,7 @@ __log_file_server(void *arg) continue; WT_ERR(__wt_fsync(session, log->log_fh, true)); __wt_spin_lock(session, &log->log_sync_lock); - locked = true; - WT_NOT_READ(locked); + WT_NOT_READ(locked, true); /* * The sync LSN could have advanced while we * were writing to disk. @@ -950,7 +949,7 @@ __log_server(void *arg) if (ret == EACCES && retry < WT_RETRY_MAX) { retry++; - ret = 0; + WT_NOT_READ(ret, 0); } else { /* * Return the error if there is diff --git a/src/third_party/wiredtiger/src/docs/Doxyfile b/src/third_party/wiredtiger/src/docs/Doxyfile index 178655bf6ed..60b6c4690b0 100644 --- a/src/third_party/wiredtiger/src/docs/Doxyfile +++ b/src/third_party/wiredtiger/src/docs/Doxyfile @@ -206,39 +206,39 @@ TAB_SIZE = 8 # You can put \n's in the value part of an alias to insert newlines. ALIASES = \ - "config{3}= @row{<tt>\1</tt>,\2,\3}" \ - "configempty{2}=@param config\n Configuration string, see @ref config_strings. No values currently permitted." \ - "configend= </table>" \ - "configstart{2}=@param config\n Configuration string, see @ref config_strings. Permitted values:\n <table>@hrow{Name,Effect,Values}" \ + config{3}=" @row{<tt>\1</tt>,\2,\3}" \ + configempty{2}="@param config configuration string, see @ref config_strings. No values currently permitted." \ + configend=" </table>" \ + configstart{2}="@param config configuration string, see @ref config_strings. Permitted values:\n <table>@hrow{Name,Effect,Values}" \ "ebusy_errors=@returns zero on success, EBUSY if the object is not available for exclusive access, and a non-zero error code on failure. See @ref error_handling \"Error handling\" for details." \ - "errors=@returns zero on success and a non-zero error code on failure. See @ref error_handling \"Error handling\" for details." \ - "exclusive=This method requires exclusive access to the specified data source(s). If any cursors are open with the specified name(s) or a data source is otherwise in use, the call will fail and return \c EBUSY.\n\n" \ - "ex_ref{1}=@ref \1 \"\1\"" \ - "hrow{1}=<tr><th>\1</th></tr>" \ - "hrow{2}=<tr><th>\1</th><th>\2</th></tr>" \ - "hrow{3}=<tr><th>\1</th><th>\2</th><th>\3</th></tr>" \ - "hrow{4}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th></tr>" \ - "hrow{5}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th></tr>" \ - "hrow{6}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th></tr>" \ - "hrow{7}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th></tr>" \ - "hrow{8}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th><th>\8</th></tr>" \ - "hrow{9}=<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th><th>\8</th><th>\9</th></tr>" \ - "notyet{1}=Note: <b>"\1"</b> not yet supported in WiredTiger.\n@todo fix when \1 supported\n\n" \ - "plantuml_end=PlantUML template end -->" \ - "plantuml_start{1}=\image html \1\n\image latex \1\n<!-- PlantUML template begins" \ - "requires_notransaction=This method must not be called on a session with an active transaction.\n\n" \ - "requires_transaction=This method must be called on a session with an active transaction.\n\n" \ - "ref_single=@ref" \ - "row{1}=<tr><td>\1</td></tr>" \ - "row{2}=<tr><td>\1</td><td>\2</td></tr>" \ - "row{3}=<tr><td>\1</td><td>\2</td><td>\3</td></tr>" \ - "row{4}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td></tr>" \ - "row{5}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td></tr>" \ - "row{6}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td></tr>" \ - "row{7}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td></tr>" \ - "row{8}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td><td>\8</td></tr>" \ - "row{9}=<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td><td>\8</td><td>\9</td></tr>" \ - "subpage_single=@subpage" \ + errors="@returns zero on success and a non-zero error code on failure. See @ref error_handling \"Error handling\" for details." \ + exclusive="This method requires exclusive access to the specified data source(s). If any cursors are open with the specified name(s) or a data source is otherwise in use, the call will fail and return \c EBUSY.\n\n" \ + ex_ref{1}="@ref \1 \"\1\"" \ + hrow{1}="<tr><th>\1</th></tr>" \ + hrow{2}="<tr><th>\1</th><th>\2</th></tr>" \ + hrow{3}="<tr><th>\1</th><th>\2</th><th>\3</th></tr>" \ + hrow{4}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th></tr>" \ + hrow{5}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th></tr>" \ + hrow{6}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th></tr>" \ + hrow{7}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th></tr>" \ + hrow{8}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th><th>\8</th></tr>" \ + hrow{9}="<tr><th>\1</th><th>\2</th><th>\3</th><th>\4</th><th>\5</th><th>\6</th><th>\7</th><th>\8</th><th>\9</th></tr>" \ + notyet{1}="Note: <b>"\1"</b> not yet supported in WiredTiger.\n@todo fix when \1 supported\n\n" \ + plantuml_end="PlantUML template end -->" \ + plantuml_start{1}="\image html \1\n\image latex \1\n<!-- PlantUML template begins" \ + requires_notransaction="This method must not be called on a session with an active transaction.\n\n" \ + requires_transaction="This method must be called on a session with an active transaction.\n\n" \ + ref_single="@ref" \ + row{1}="<tr><td>\1</td></tr>" \ + row{2}="<tr><td>\1</td><td>\2</td></tr>" \ + row{3}="<tr><td>\1</td><td>\2</td><td>\3</td></tr>" \ + row{4}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td></tr>" \ + row{5}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td></tr>" \ + row{6}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td></tr>" \ + row{7}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td></tr>" \ + row{8}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td><td>\8</td></tr>" \ + row{9}="<tr><td>\1</td><td>\2</td><td>\3</td><td>\4</td><td>\5</td><td>\6</td><td>\7</td><td>\8</td><td>\9</td></tr>" \ + subpage_single="@subpage" \ # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding diff --git a/src/third_party/wiredtiger/src/evict/evict_page.c b/src/third_party/wiredtiger/src/evict/evict_page.c index 90b71659015..5c478654585 100644 --- a/src/third_party/wiredtiger/src/evict/evict_page.c +++ b/src/third_party/wiredtiger/src/evict/evict_page.c @@ -124,22 +124,36 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) bool clean_page, inmem_split, tree_dead; conn = S2C(session); + page = ref->page; + + __wt_verbose(session, WT_VERB_EVICT, + "page %p (%s)", (void *)page, __wt_page_type_string(page->type)); /* Enter the eviction generation. */ __wt_session_gen_enter(session, WT_GEN_EVICT); - page = ref->page; - tree_dead = F_ISSET(session->dhandle, WT_DHANDLE_DEAD); + /* + * Get exclusive access to the page if our caller doesn't have the tree + * locked down. + */ + if (!closing) { + WT_ERR(__evict_exclusive(session, ref)); - __wt_verbose(session, WT_VERB_EVICT, - "page %p (%s)", (void *)page, __wt_page_type_string(page->type)); + /* + * Now the page is locked, remove it from the LRU eviction + * queue. We have to do this before freeing the page memory or + * otherwise touching the reference because eviction paths + * assume a non-NULL reference on the queue is pointing at + * valid memory. + */ + __wt_evict_list_clear_page(session, ref); + } /* - * Get exclusive access to the page and review it for conditions that - * would block our eviction of the page. If the check fails (for - * example, we find a page with active children), we're done. We have - * to make this check for clean pages, too: while unlikely eviction - * would choose an internal page with children, it's not disallowed. + * Review the page for conditions that would block its eviction. If the + * check fails (for example, we find a page with active children), quit. + * Make this check for clean pages, too: while unlikely eviction would + * choose an internal page with children, it's not disallowed. */ WT_ERR(__evict_review(session, ref, closing, &inmem_split)); @@ -178,6 +192,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) } /* Update the reference and discard the page. */ + tree_dead = F_ISSET(session->dhandle, WT_DHANDLE_DEAD); if (__wt_ref_is_root(ref)) __wt_ref_out(session, ref); else if ((clean_page && !F_ISSET(conn, WT_CONN_IN_MEMORY)) || tree_dead) @@ -275,12 +290,11 @@ __evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) WT_DECL_RET; /* - * Discard the page and update the reference structure; if the page has - * an address, it's a disk page; if it has no address, it's a deleted - * page re-instantiated (for example, by searching) and never written. - * - * If evicting a WT_REF_LIMBO reference, we get to here and transition - * back to WT_REF_LOOKASIDE. + * Discard the page and update the reference structure. If evicting a + * WT_REF_LIMBO page, transition back to WT_REF_LOOKASIDE. Otherwise, + * a page with a disk address is an on-disk page, and a page without + * a disk address is a re-instantiated deleted page (for example, by + * searching), that was never subsequently written. */ __wt_ref_out(session, ref); if (!closing && ref->page_las != NULL && @@ -417,7 +431,18 @@ __evict_child_check(WT_SESSION_IMPL *session, WT_REF *parent) WT_INTL_FOREACH_BEGIN(session, parent->page, child) { switch (child->state) { case WT_REF_DISK: /* On-disk */ - case WT_REF_DELETED: /* On-disk, deleted */ + break; + case WT_REF_DELETED: /* Deleted */ + /* + * If the page was part of a truncate, transaction + * rollback might switch this page into its previous + * state at any time, so the delete must be resolved. + * We don't have to lock the page, as no thread of + * control can be running below our locked internal + * page. + */ + if (__wt_btree_truncate_active(session, child)) + return (EBUSY); break; default: return (EBUSY); @@ -446,31 +471,12 @@ __evict_review( *inmem_splitp = false; conn = S2C(session); + page = ref->page; flags = WT_REC_EVICT; if (!WT_SESSION_IS_CHECKPOINT(session)) LF_SET(WT_REC_VISIBLE_ALL); /* - * Get exclusive access to the page if our caller doesn't have the tree - * locked down. - */ - if (!closing) { - WT_RET(__evict_exclusive(session, ref)); - - /* - * Now the page is locked, remove it from the LRU eviction - * queue. We have to do this before freeing the page memory or - * otherwise touching the reference because eviction paths - * assume a non-NULL reference on the queue is pointing at - * valid memory. - */ - __wt_evict_list_clear_page(session, ref); - } - - /* Now that we have exclusive access, review the page. */ - page = ref->page; - - /* * Fail if an internal has active children, the children must be evicted * first. The test is necessary but shouldn't fire much: the eviction * code is biased for leaf pages, an internal page shouldn't be selected diff --git a/src/third_party/wiredtiger/src/include/api.h b/src/third_party/wiredtiger/src/include/api.h index ff757c4bfb5..ca2176fcf0e 100644 --- a/src/third_party/wiredtiger/src/include/api.h +++ b/src/third_party/wiredtiger/src/include/api.h @@ -238,7 +238,8 @@ JOINABLE_CURSOR_CALL_CHECK(cur) #define CURSOR_UPDATE_API_END(s, ret) \ - ((ret == WT_PREPARE_CONFLICT) ? (ret = WT_ROLLBACK) : ret ); \ + if ((ret) == WT_PREPARE_CONFLICT) \ + (ret) = WT_ROLLBACK; \ TXN_API_END(s, ret) #define ASYNCOP_API_CALL(conn, s, n) \ diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index d56a3773933..893f51aa022 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -773,7 +773,7 @@ struct __wt_page { /* * WT_PAGE_DELETED -- - * Related information for fast-delete, on-disk pages. + * Related information for truncated pages. */ struct __wt_page_deleted { volatile uint64_t txnid; /* Transaction ID */ diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i index 808c8f7ee7f..de28eb7232f 100644 --- a/src/third_party/wiredtiger/src/include/btree.i +++ b/src/third_party/wiredtiger/src/include/btree.i @@ -1151,6 +1151,23 @@ __wt_ref_block_free(WT_SESSION_IMPL *session, WT_REF *ref) } /* + * __wt_btree_truncate_active -- + * Return if a truncate operation is active. + */ +static inline bool +__wt_btree_truncate_active(WT_SESSION_IMPL *session, WT_REF *ref) +{ + WT_PAGE_DELETED *page_del; + + if ((page_del = ref->page_del) == NULL) + return (false); + if (page_del->txnid == WT_TXN_ABORTED) + return (false); + return (!__wt_txn_visible_all(session, + page_del->txnid, WT_TIMESTAMP_NULL(&page_del->timestamp))); +} + +/* * __wt_btree_can_evict_dirty -- * Check whether eviction of dirty pages or splits are permitted in the * current tree. @@ -1336,7 +1353,11 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool *inmem_splitp) page = ref->page; mod = page->modify; - /* Pages that have never been modified can always be evicted. */ + /* A truncated page can't be evicted until the truncate completes. */ + if (__wt_btree_truncate_active(session, ref)) + return (false); + + /* Otherwise, never modified pages can always be evicted. */ if (mod == NULL) return (true); @@ -1350,12 +1371,6 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool *inmem_splitp) F_ISSET_ATOMIC(ref->home, WT_PAGE_OVERFLOW_KEYS)) return (false); - /* A truncated page can't be evicted until the truncate completes. */ - if (ref->page_del != NULL && ref->page_del->txnid != WT_TXN_ABORTED && - !__wt_txn_visible_all(session, - ref->page_del->txnid, WT_TIMESTAMP_NULL(&ref->page_del->timestamp))) - return (false); - /* * Check for in-memory splits before other eviction tests. If the page * should split in-memory, return success immediately and skip more @@ -1458,7 +1473,8 @@ __wt_page_release(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) (LF_ISSET(WT_READ_NO_SPLIT) || (!inmem_split && F_ISSET(session, WT_SESSION_NO_RECONCILE)))) { if (!WT_SESSION_IS_CHECKPOINT(session)) - (void)__wt_page_evict_urgent(session, ref); + WT_IGNORE_RET( + __wt_page_evict_urgent(session, ref)); } else { WT_RET_BUSY_OK(__wt_page_release_evict(session, ref)); return (0); diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 508480b95c2..d884401feb2 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -68,7 +68,7 @@ extern int __wt_block_ext_prealloc(WT_SESSION_IMPL *session, u_int max) WT_GCC_F extern int __wt_block_ext_discard(WT_SESSION_IMPL *session, u_int max) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_salvage_start(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size); +extern bool __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, bool *eofp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -128,7 +128,7 @@ extern int __wt_debug_tree(WT_SESSION_IMPL *session, WT_BTREE *btree, WT_REF *re extern int __wt_debug_page(WT_SESSION_IMPL *session, WT_REF *ref, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all); +extern bool __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref); extern void __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep); @@ -141,7 +141,7 @@ extern int __wt_btree_discard(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBU extern void __wt_root_ref_init(WT_REF *root_ref, WT_PAGE *root, bool is_recno); extern int __wt_btree_tree_open(WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btree_new_leaf_page(WT_SESSION_IMPL *session, WT_PAGE **pagep) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_btree_immediately_durable(WT_SESSION_IMPL *session); +extern bool __wt_btree_immediately_durable(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btree_huffman_open(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_btree_huffman_close(WT_SESSION_IMPL *session); extern int __wt_bt_read(WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -200,15 +200,15 @@ extern int __wt_update_alloc(WT_SESSION_IMPL *session, const WT_ITEM *value, WT_ extern WT_UPDATE *__wt_update_obsolete_check(WT_SESSION_IMPL *session, WT_PAGE *page, WT_UPDATE *upd); extern int __wt_search_insert(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_INSERT_HEAD *ins_head, WT_ITEM *srch_key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_row_search(WT_SESSION_IMPL *session, WT_ITEM *srch_key, WT_REF *leaf, WT_CURSOR_BTREE *cbt, bool insert, bool restore) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_las_nonempty(WT_SESSION_IMPL *session); +extern bool __wt_las_nonempty(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_las_stats_update(WT_SESSION_IMPL *session); extern int __wt_las_create(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_cursor_open(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_las_cursor(WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t *session_flags); extern int __wt_las_cursor_close(WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t session_flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_las_page_skip_locked(WT_SESSION_IMPL *session, WT_REF *ref); -extern bool __wt_las_page_skip(WT_SESSION_IMPL *session, WT_REF *ref); +extern bool __wt_las_page_skip_locked(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern bool __wt_las_page_skip(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_insert_block(WT_SESSION_IMPL *session, WT_CURSOR *cursor, WT_PAGE *page, WT_MULTI *multi, WT_ITEM *key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_cursor_position(WT_CURSOR *cursor, uint32_t btree_id, uint64_t pageid) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_remove_block(WT_SESSION_IMPL *session, uint32_t btree_id, uint64_t pageid) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -369,7 +369,7 @@ extern int __wt_curtable_open(WT_SESSION_IMPL *session, const char *uri, WT_CURS extern int __wt_evict_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_evict_list_clear_page(WT_SESSION_IMPL *session, WT_REF *ref); extern void __wt_evict_server_wake(WT_SESSION_IMPL *session); -extern bool __wt_evict_thread_chk(WT_SESSION_IMPL *session); +extern bool __wt_evict_thread_chk(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_evict_thread_run(WT_SESSION_IMPL *session, WT_THREAD *thread) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_evict_thread_stop(WT_SESSION_IMPL *session, WT_THREAD *thread) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_evict_create(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -377,7 +377,7 @@ extern int __wt_evict_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBU extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session); extern int __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, bool readonly, double pct_full) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_page_evict_urgent(WT_SESSION_IMPL *session, WT_REF *ref); +extern bool __wt_page_evict_urgent(WT_SESSION_IMPL *session, WT_REF *ref) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_evict_priority_set(WT_SESSION_IMPL *session, uint64_t v); extern void __wt_evict_priority_clear(WT_SESSION_IMPL *session); extern int __wt_verbose_dump_cache(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -495,7 +495,7 @@ extern int __wt_lsm_tree_worker(WT_SESSION_IMPL *session, const char *uri, int ( extern int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool force, WT_LSM_CHUNK **chunkp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_work_switch(WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, bool *ran) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_lsm_chunk_visible_all(WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk); +extern bool __wt_lsm_chunk_visible_all(WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_worker_start(WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *args) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -557,7 +557,7 @@ extern void __wt_free_int(WT_SESSION_IMPL *session, const void *p_arg) WT_GCC_FU extern int __wt_errno(void) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_strerror(WT_SESSION_IMPL *session, int error, char *errbuf, size_t errlen); extern int __wt_ext_map_windows_error(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, uint32_t windows_error) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_handle_is_open(WT_SESSION_IMPL *session, const char *name); +extern bool __wt_handle_is_open(WT_SESSION_IMPL *session, const char *name) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_open(WT_SESSION_IMPL *session, const char *name, WT_FS_OPEN_FILE_TYPE file_type, u_int flags, WT_FH **fhp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_close(WT_SESSION_IMPL *session, WT_FH **fhp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_close_connection_close(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -742,11 +742,11 @@ extern void __wt_readunlock(WT_SESSION_IMPL *session, WT_RWLOCK *l); extern int __wt_try_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *l) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *l); extern void __wt_writeunlock(WT_SESSION_IMPL *session, WT_RWLOCK *l); -extern bool __wt_rwlock_islocked(WT_SESSION_IMPL *session, WT_RWLOCK *l); +extern bool __wt_rwlock_islocked(WT_SESSION_IMPL *session, WT_RWLOCK *l) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern uint32_t __wt_nlpo2_round(uint32_t v); extern uint32_t __wt_nlpo2(uint32_t v); extern uint32_t __wt_log2_int(uint32_t n); -extern bool __wt_ispo2(uint32_t v); +extern bool __wt_ispo2(uint32_t v) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern uint32_t __wt_rduppo2(uint32_t n, uint32_t po2); extern void __wt_random_init(WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); extern void __wt_random_init_seed(WT_SESSION_IMPL *session, WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); diff --git a/src/third_party/wiredtiger/src/include/extern_posix.h b/src/third_party/wiredtiger/src/include/extern_posix.h index bc71b77d0f6..8b92d99d4f1 100644 --- a/src/third_party/wiredtiger/src/include/extern_posix.h +++ b/src/third_party/wiredtiger/src/include/extern_posix.h @@ -19,9 +19,9 @@ extern void __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond); extern void __wt_cond_destroy(WT_SESSION_IMPL *session, WT_CONDVAR **condp); extern int __wt_once(void (*init_routine)(void)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_get_vm_pagesize(void) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_absolute_path(const char *path); +extern bool __wt_absolute_path(const char *path) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_path_separator(void); -extern bool __wt_has_priv(void); +extern bool __wt_has_priv(void) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_stream_set_line_buffer(FILE *fp) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); extern void __wt_stream_set_no_buffer(FILE *fp) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); extern void __wt_sleep(uint64_t seconds, uint64_t micro_seconds) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); diff --git a/src/third_party/wiredtiger/src/include/extern_win.h b/src/third_party/wiredtiger/src/include/extern_win.h index bdd54b7954a..50808750c56 100644 --- a/src/third_party/wiredtiger/src/include/extern_win.h +++ b/src/third_party/wiredtiger/src/include/extern_win.h @@ -17,9 +17,9 @@ extern void __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond); extern void __wt_cond_destroy(WT_SESSION_IMPL *session, WT_CONDVAR **condp); extern int __wt_once(void (*init_routine)(void)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_get_vm_pagesize(void) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_absolute_path(const char *path); +extern bool __wt_absolute_path(const char *path) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_path_separator(void); -extern bool __wt_has_priv(void); +extern bool __wt_has_priv(void) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_stream_set_line_buffer(FILE *fp); extern void __wt_stream_set_no_buffer(FILE *fp); extern void __wt_sleep(uint64_t seconds, uint64_t micro_seconds); @@ -30,8 +30,8 @@ extern void __wt_thread_id(uintmax_t *id); extern int __wt_thread_str(char *buf, size_t buflen) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern uintmax_t __wt_process_id(void); extern void __wt_epoch_raw(WT_SESSION_IMPL *session, struct timespec *tsp); -extern int __wt_to_utf16_string(WT_SESSION_IMPL *session, const char*utf8, WT_ITEM **outbuf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_to_utf8_string(WT_SESSION_IMPL *session, const wchar_t*wide, WT_ITEM **outbuf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_to_utf16_string(WT_SESSION_IMPL *session, const char *utf8, WT_ITEM **outbuf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_to_utf8_string(WT_SESSION_IMPL *session, const wchar_t *wide, WT_ITEM **outbuf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern DWORD __wt_getlasterror(void); extern int __wt_map_windows_error(DWORD windows_error) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_formatmessage(WT_SESSION_IMPL *session, DWORD windows_error); diff --git a/src/third_party/wiredtiger/src/include/misc.h b/src/third_party/wiredtiger/src/include/misc.h index a3a81c21569..c4d7def85c0 100644 --- a/src/third_party/wiredtiger/src/include/misc.h +++ b/src/third_party/wiredtiger/src/include/misc.h @@ -11,7 +11,10 @@ * and unused function return values. */ #define WT_UNUSED(var) (void)(var) -#define WT_NOT_READ(var) (void)(var) +#define WT_NOT_READ(v, val) do { \ + (v) = (val); \ + (void)(v); \ +} while (0); #define WT_IGNORE_RET(call) do { \ int __ignored_ret; \ __ignored_ret = (call); \ diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i index 36cac1a26f3..9061157ff5a 100644 --- a/src/third_party/wiredtiger/src/include/txn.i +++ b/src/third_party/wiredtiger/src/include/txn.i @@ -296,7 +296,7 @@ __wt_txn_modify(WT_SESSION_IMPL *session, WT_UPDATE *upd) /* * __wt_txn_modify_page_delete -- - * Remember a page fast-deleted by the current transaction. + * Remember a page truncated by the current transaction. */ static inline int __wt_txn_modify_page_delete(WT_SESSION_IMPL *session, WT_REF *ref) diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 7050a66a558..4d9f6f92832 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -593,7 +593,7 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { if (clsm->chunks != NULL && ngood < clsm->nchunks) { close_range_start = ngood; close_range_end = clsm->nchunks; - } else if (!F_ISSET(clsm, WT_CLSM_OPEN_READ) && nupdates > 0 ) { + } else if (!F_ISSET(clsm, WT_CLSM_OPEN_READ) && nupdates > 0) { close_range_start = 0; close_range_end = WT_MIN(nchunks, clsm->nchunks); if (close_range_end > nupdates) diff --git a/src/third_party/wiredtiger/src/lsm/lsm_tree.c b/src/third_party/wiredtiger/src/lsm/lsm_tree.c index 1b92028072d..9a7ab20f18f 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_tree.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_tree.c @@ -911,8 +911,7 @@ __wt_lsm_tree_drop( int tret; bool locked; - locked = false; - WT_NOT_READ(locked); + WT_NOT_READ(locked, false); /* Get the LSM tree. */ WT_RET(__wt_lsm_tree_get(session, name, true, &lsm_tree)); @@ -971,8 +970,7 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session, bool locked; old = NULL; - locked = false; - WT_NOT_READ(locked); + WT_NOT_READ(locked, false); /* Get the LSM tree. */ WT_RET(__wt_lsm_tree_get(session, olduri, true, &lsm_tree)); @@ -1043,8 +1041,7 @@ __wt_lsm_tree_truncate( WT_UNUSED(cfg); chunk = NULL; - locked = false; - WT_NOT_READ(locked); + WT_NOT_READ(locked, false); /* Get the LSM tree. */ WT_RET(__wt_lsm_tree_get(session, name, true, &lsm_tree)); @@ -1382,8 +1379,8 @@ __wt_lsm_tree_worker(WT_SESSION_IMPL *session, u_int i; bool exclusive, locked, need_release; - locked = need_release = false; - WT_NOT_READ(locked); + WT_NOT_READ(locked, false); + WT_NOT_READ(need_release, false); exclusive = FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE); WT_RET(__wt_lsm_tree_get(session, uri, exclusive, &lsm_tree)); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c index dcb9b34802a..6f18f4fb152 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -345,8 +345,8 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, WT_TXN_ISOLATION saved_isolation; bool flush_set, release_dhandle; - flush_set = release_dhandle = false; - WT_NOT_READ(flush_set); + WT_NOT_READ(flush_set, false); + release_dhandle = false; /* * If the chunk is already checkpointed, make sure it is also evicted. @@ -360,8 +360,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, if (ret == 0) chunk->evicted = 1; else if (ret == EBUSY) { - ret = 0; - WT_NOT_READ(ret); + WT_NOT_READ(ret, 0); } else WT_RET_MSG(session, ret, "discard handle"); } diff --git a/src/third_party/wiredtiger/src/os_posix/os_fs.c b/src/third_party/wiredtiger/src/os_posix/os_fs.c index ca810fa8d88..811c0576eef 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_fs.c +++ b/src/third_party/wiredtiger/src/os_posix/os_fs.c @@ -97,7 +97,7 @@ __posix_directory_sync(WT_SESSION_IMPL *session, const char *path) dir = tmp->mem; strrchr(dir, '/')[1] = '\0'; - fd = -1; /* -Wconditional-uninitialized */ + fd = 0; /* -Wconditional-uninitialized */ WT_SYSCALL_RETRY(( (fd = open(dir, O_RDONLY, 0444)) == -1 ? -1 : 0), ret); if (ret != 0) diff --git a/src/third_party/wiredtiger/src/os_win/os_dir.c b/src/third_party/wiredtiger/src/os_win/os_dir.c index 3b78106f3b4..d5095e7ef78 100644 --- a/src/third_party/wiredtiger/src/os_win/os_dir.c +++ b/src/third_party/wiredtiger/src/os_win/os_dir.c @@ -59,30 +59,41 @@ __directory_list_worker(WT_FILE_SYSTEM *file_system, WT_ERR(__wt_map_windows_error(windows_error)); } - count = 0; - do { + for (count = 0;;) { /* * Skip . and .. */ if (wcscmp(finddata.cFileName, L".") == 0 || wcscmp(finddata.cFileName, L"..") == 0) - continue; + goto skip; /* The list of files is optionally filtered by a prefix. */ if (prefix != NULL && wcsncmp(finddata.cFileName, prefix_wide->data, prefix_widelen) != 0) - continue; + goto skip; WT_ERR(__wt_realloc_def( session, &dirallocsz, count + 1, &entries)); - WT_ERR(__wt_to_utf8_string( session, finddata.cFileName, &file_utf8)); WT_ERR(__wt_strdup(session, file_utf8->data, &entries[count])); ++count; __wt_scr_free(session, &file_utf8); - } while (!single && FindNextFileW(findhandle, &finddata) != 0); + + if (single) + break; + +skip: if (FindNextFileW(findhandle, &finddata) != 0) + continue; + windows_error = __wt_getlasterror(); + if (windows_error == ERROR_NO_MORE_FILES) + break; + __wt_errx(session, + "%s: directory-list: FindNextFileW: %s", + pathbuf->data, __wt_formatmessage(session, windows_error)); + WT_ERR(__wt_map_windows_error(windows_error)); + } *dirlistp = entries; *countp = count; diff --git a/src/third_party/wiredtiger/src/os_win/os_utf8.c b/src/third_party/wiredtiger/src/os_win/os_utf8.c index 077c39db3ef..1c9efe39506 100644 --- a/src/third_party/wiredtiger/src/os_win/os_utf8.c +++ b/src/third_party/wiredtiger/src/os_win/os_utf8.c @@ -14,7 +14,7 @@ */ int __wt_to_utf16_string( - WT_SESSION_IMPL *session, const char* utf8, WT_ITEM **outbuf) + WT_SESSION_IMPL *session, const char *utf8, WT_ITEM **outbuf) { DWORD windows_error; int bufferSize; @@ -50,7 +50,7 @@ __wt_to_utf16_string( */ int __wt_to_utf8_string( - WT_SESSION_IMPL *session, const wchar_t* wide, WT_ITEM **outbuf) + WT_SESSION_IMPL *session, const wchar_t *wide, WT_ITEM **outbuf) { DWORD windows_error; int bufferSize; diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index a2ce2c136b5..1c46da9be10 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -1785,12 +1785,12 @@ __rec_child_modify(WT_SESSION_IMPL *session, /* * If called during checkpoint, the child is being * considered by the eviction server or the child is a - * fast-delete page being read. The eviction may have + * truncated page being read. The eviction may have * started before the checkpoint and so we must wait * for the eviction to be resolved. I suspect we could - * handle fast-delete reads, but we can't distinguish - * between the two and fast-delete reads aren't expected - * to be common. + * handle reads of truncated pages, but we can't + * distinguish between the two and reads of truncated + * pages aren't expected to be common. */ break; @@ -5632,8 +5632,7 @@ build: if (key_onpage_ovfl) { WT_ERR(__wt_dsk_cell_data_ref(session, WT_PAGE_ROW_LEAF, kpack, r->cur)); - key_onpage_ovfl = false; - WT_NOT_READ(key_onpage_ovfl); + WT_NOT_READ(key_onpage_ovfl, false); } /* diff --git a/src/third_party/wiredtiger/src/support/mtx_rw.c b/src/third_party/wiredtiger/src/support/mtx_rw.c index b554f589b3d..fd66a1a40bb 100644 --- a/src/third_party/wiredtiger/src/support/mtx_rw.c +++ b/src/third_party/wiredtiger/src/support/mtx_rw.c @@ -178,12 +178,10 @@ __wt_readlock(WT_SESSION_IMPL *session, WT_RWLOCK *l) int pause_cnt; bool set_stats; + stats = NULL; /* -Wconditional-uninitialized */ + time_start = time_stop = 0; /* -Wconditional-uninitialized */ + WT_STAT_CONN_INCR(session, rwlock_read); - stats = (int64_t **)S2C(session)->stats; - set_stats = (l->stat_read_count_off != -1 && WT_STAT_ENABLED(session)); - time_start = time_stop = 0; - if (set_stats) - stats[session->stat_bucket][l->stat_read_count_off]++; WT_DIAGNOSTIC_YIELD; @@ -241,8 +239,12 @@ stall: __wt_cond_wait(session, break; } - if (set_stats) + set_stats = (l->stat_read_count_off != -1 && WT_STAT_ENABLED(session)); + if (set_stats) { + stats = (int64_t **)S2C(session)->stats; + stats[session->stat_bucket][l->stat_read_count_off]++; time_start = __wt_clock(session); + } /* Wait for our group to start. */ for (pause_cnt = 0; ticket != l->u.s.current; pause_cnt++) { if (pause_cnt < 1000) @@ -375,12 +377,10 @@ __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *l) int pause_cnt; bool set_stats; + stats = NULL; /* -Wconditional-uninitialized */ + time_start = time_stop = 0; /* -Wconditional-uninitialized */ + WT_STAT_CONN_INCR(session, rwlock_write); - stats = (int64_t **)S2C(session)->stats; - set_stats = (l->stat_write_count_off != -1 && WT_STAT_ENABLED(session)); - time_start = time_stop = 0; - if (set_stats) - stats[session->stat_bucket][l->stat_write_count_off]++; for (;;) { old.u.v = l->u.v; @@ -403,6 +403,12 @@ __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *l) break; } + set_stats = (l->stat_write_count_off != -1 && WT_STAT_ENABLED(session)); + if (set_stats) { + stats = (int64_t **)S2C(session)->stats; + stats[session->stat_bucket][l->stat_write_count_off]++; + time_start = __wt_clock(session); + } /* * Wait for our group to start and any readers to drain. * @@ -411,8 +417,6 @@ __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *l) * could see no readers active from a different batch and decide that * we have the lock. */ - if (set_stats) - time_start = __wt_clock(session); for (pause_cnt = 0, old.u.v = l->u.v; ticket != old.u.s.current || old.u.s.readers_active != 0; pause_cnt++, old.u.v = l->u.v) { diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index 561961f4e98..3a9b3755ff5 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -1394,8 +1394,7 @@ __wt_verbose_dump_txn_one(WT_SESSION_IMPL *session, WT_TXN *txn) #endif const char *iso_tag; - iso_tag = "INVALID"; - WT_NOT_READ(iso_tag); + WT_NOT_READ(iso_tag, "INVALID"); switch (txn->isolation) { case WT_ISO_READ_COMMITTED: iso_tag = "WT_ISO_READ_COMMITTED"; diff --git a/src/third_party/wiredtiger/src/utilities/util_load.c b/src/third_party/wiredtiger/src/utilities/util_load.c index 3ed21fc591c..dab24930fe6 100644 --- a/src/third_party/wiredtiger/src/utilities/util_load.c +++ b/src/third_party/wiredtiger/src/utilities/util_load.c @@ -124,8 +124,10 @@ load_dump(WT_SESSION *session) "dump=%s%s%s", hex ? "hex" : "print", append ? ",append" : "", - no_overwrite ? ",overwrite=false" : "")) != 0) - return (util_err(session, ret, NULL)); + no_overwrite ? ",overwrite=false" : "")) != 0) { + ret = util_err(session, ret, NULL); + goto err; + } if ((ret = session->open_cursor( session, uri, NULL, config, &cursor)) != 0) { ret = util_err(session, ret, "%s: session.open_cursor", uri); @@ -494,8 +496,10 @@ config_rename(WT_SESSION *session, char **urip, const char *name) *p = '\0'; p = strchr(p + 1, ':'); if ((ret = __wt_snprintf( - buf, len, "%s:%s%s", *urip, name, p == NULL ? "" : p)) != 0) + buf, len, "%s:%s%s", *urip, name, p == NULL ? "" : p)) != 0) { + free(buf); return (util_err(session, ret, NULL)); + } *urip = buf; return (0); diff --git a/src/third_party/wiredtiger/test/bloom/test_bloom.c b/src/third_party/wiredtiger/test/bloom/test_bloom.c index 10607a3719c..dcc7ab372a9 100644 --- a/src/third_party/wiredtiger/test/bloom/test_bloom.c +++ b/src/third_party/wiredtiger/test/bloom/test_bloom.c @@ -39,7 +39,8 @@ static struct { uint32_t c_ops; uint32_t c_k; /* Number of hash iterations */ uint32_t c_factor; /* Number of bits per item */ - uint32_t c_srand; + + WT_RAND_STATE rand; uint8_t **entries; } g; @@ -67,10 +68,9 @@ main(int argc, char *argv[]) g.c_key_max = 100; g.c_k = 8; g.c_factor = 16; - g.c_srand = 3233456; /* Set values from the command line. */ - while ((ch = __wt_getopt(progname, argc, argv, "c:f:k:o:s:")) != EOF) + while ((ch = __wt_getopt(progname, argc, argv, "c:f:k:o:")) != EOF) switch (ch) { case 'c': /* Cache size */ g.c_cache = (u_int)atoi(__wt_optarg); @@ -78,15 +78,12 @@ main(int argc, char *argv[]) case 'f': /* Factor */ g.c_factor = (u_int)atoi(__wt_optarg); break; - case 'k': /* Number of hash functions */ + case 'k': /* Number of hash functions */ g.c_k = (u_int)atoi(__wt_optarg); break; case 'o': /* Number of ops */ g.c_ops = (u_int)atoi(__wt_optarg); break; - case 's': /* Number of ops */ - g.c_srand = (u_int)atoi(__wt_optarg); - break; default: usage(); } @@ -184,7 +181,7 @@ run(void) memset((void *)item.data, 'a', item.size); for (i = 0, fp = 0; i < g.c_ops; i++) { ((uint8_t *)item.data)[i % item.size] = - 'a' + ((uint8_t)rand() % 26); + 'a' + (__wt_random(&g.rand) % 26); if ((ret = __wt_bloom_get(bloomp, &item)) == 0) ++fp; if (ret != 0 && ret != WT_NOTFOUND) @@ -219,14 +216,14 @@ populate_entries(void) uint32_t i, j; uint8_t **entries; - srand(g.c_srand); + __wt_random_init_seed(NULL, &g.rand); entries = dcalloc(g.c_ops, sizeof(uint8_t *)); for (i = 0; i < g.c_ops; i++) { entries[i] = dcalloc(g.c_key_max, sizeof(uint8_t)); for (j = 0; j < g.c_key_max; j++) - entries[i][j] = 'a' + ((uint8_t)rand() % 26); + entries[i][j] = 'a' + (__wt_random(&g.rand) % 26); } g.entries = entries; @@ -239,13 +236,12 @@ populate_entries(void) void usage(void) { - fprintf(stderr, "usage: %s [-cfkos]\n", progname); + fprintf(stderr, "usage: %s [-cfko]\n", progname); fprintf(stderr, "%s", "\t-c cache size\n" "\t-f number of bits per item\n" "\t-k size of entry strings\n" - "\t-o number of operations to perform\n" - "\t-s random seed for run\n"); + "\t-o number of operations to perform\n"); exit(EXIT_FAILURE); } diff --git a/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c b/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c index 232cb53e540..8a1781eae45 100644 --- a/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c +++ b/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c @@ -64,7 +64,7 @@ static char home[1024]; /* Program working dir */ #define MIN_TH 5 #define MIN_TIME 10 #define PREPARE_FREQ 5 -#define PREPARE_YIELD PREPARE_FREQ * 10 +#define PREPARE_YIELD (PREPARE_FREQ * 10) #define RECORDS_FILE "records-%" PRIu32 #define STABLE_PERIOD 100 diff --git a/src/third_party/wiredtiger/test/format/ops.c b/src/third_party/wiredtiger/test/format/ops.c index 2466fe4d64d..596d952dcc6 100644 --- a/src/third_party/wiredtiger/test/format/ops.c +++ b/src/third_party/wiredtiger/test/format/ops.c @@ -1379,7 +1379,7 @@ nextprev(TINFO *tinfo, WT_CURSOR *cursor, bool next) return (ret); } - if (g.logging == LOG_OPS) + if (ret == 0 && g.logging == LOG_OPS) switch (g.type) { case FIX: (void)g.wt_api->msg_printf(g.wt_api, diff --git a/src/third_party/wiredtiger/test/suite/test_bug019.py b/src/third_party/wiredtiger/test/suite/test_bug019.py new file mode 100644 index 00000000000..202ca6b6b60 --- /dev/null +++ b/src/third_party/wiredtiger/test/suite/test_bug019.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# +# Public Domain 2014-2018 MongoDB, Inc. +# Public Domain 2008-2014 WiredTiger, Inc. +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +import fnmatch, os, time +import wiredtiger, wttest +from wtdataset import SimpleDataSet + +# test_bug019.py +# Test that pre-allocating log files only pre-allocates a small number. +class test_bug019(wttest.WiredTigerTestCase): + conn_config = 'log=(enabled,file_max=100K)' + uri = "table:bug019" + entries = 100000 + + # Modify rows so we write log records. We're writing a lot more than a + # single log file, so we know the underlying library will churn through + # log files. + def populate(self, nentries): + c = self.session.open_cursor(self.uri, None, None) + for i in range(0, nentries): + c[i] = i + c.close() + + # Wait for a log file to be pre-allocated. Avoid timing problems, but + # assert a file is created within 30 seconds. + def prepfiles(self): + for i in range(1,30): + f = fnmatch.filter(os.listdir('.'), "*Prep*") + if f: + return f + time.sleep(1) + self.assertFalse(not f) + + # There was a bug where pre-allocated log files accumulated on + # Windows systems due to an issue with the directory list code. + def test_bug019(self): + # Create a table just to write something into the log. + self.session.create(self.uri, 'key_format=i,value_format=i') + self.populate(self.entries) + self.session.checkpoint() + + # Loop, making sure pre-allocation is working and the range is moving. + older = self.prepfiles() + for i in range(1, 10): + self.populate(self.entries) + newer = self.prepfiles() + + # Files can be returned in any order when reading a directory, older + # pre-allocated files can persist longer than newer files when newer + # files are returned first. Confirm files are being consumed. + self.assertFalse(set(older) < set(newer)) + + older = newer + self.session.checkpoint() + +if __name__ == '__main__': + wttest.run() diff --git a/src/third_party/wiredtiger/test/suite/test_cursor13.py b/src/third_party/wiredtiger/test/suite/test_cursor13.py index 27884b6726c..35a841ed78d 100644 --- a/src/third_party/wiredtiger/test/suite/test_cursor13.py +++ b/src/third_party/wiredtiger/test/suite/test_cursor13.py @@ -509,7 +509,7 @@ class test_cursor13_sweep(test_cursor13_big_base): swept = end_sweep_stats[3] - begin_sweep_stats[3] # Although this is subject to tuning parameters, we know that - # in an active sesssion, we'll sweep through minimum of 1% of + # in an active session, we'll sweep through minimum of 1% of # the cached cursors per second. We've set this test to run # 5 rounds. In 2 of the 5 rounds (sandwiched between the others), # some of the uris are allowed to close. So during the 'closing rounds' |