diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/btree')
20 files changed, 195 insertions, 124 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_curnext.c b/src/third_party/wiredtiger/src/btree/bt_curnext.c index 3a031b49db5..0aa446fc974 100644 --- a/src/third_party/wiredtiger/src/btree/bt_curnext.c +++ b/src/third_party/wiredtiger/src/btree/bt_curnext.c @@ -457,7 +457,7 @@ __wt_cursor_key_order_check( return (__cursor_key_order_check_col(session, cbt, next)); case WT_PAGE_ROW_LEAF: return (__cursor_key_order_check_row(session, cbt, next)); - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, cbt->ref->page->type); } /* NOTREACHED */ } @@ -482,7 +482,7 @@ __wt_cursor_key_order_init(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) case WT_PAGE_ROW_LEAF: return (__wt_buf_set(session, cbt->lastkey, cbt->iface.key.data, cbt->iface.key.size)); - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, cbt->ref->page->type); } /* NOTREACHED */ } @@ -642,7 +642,7 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating) case WT_PAGE_COL_VAR: ret = __cursor_var_append_next(cbt, newpage); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } if (ret == 0) break; @@ -660,7 +660,7 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating) case WT_PAGE_ROW_LEAF: ret = __cursor_row_next(cbt, newpage); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } if (ret != WT_NOTFOUND) break; diff --git a/src/third_party/wiredtiger/src/btree/bt_curprev.c b/src/third_party/wiredtiger/src/btree/bt_curprev.c index 9b8ca471749..9647fdc9b2d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_curprev.c +++ b/src/third_party/wiredtiger/src/btree/bt_curprev.c @@ -606,7 +606,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating) case WT_PAGE_COL_VAR: ret = __cursor_var_append_prev(cbt, newpage); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } if (ret == 0) break; @@ -626,7 +626,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating) case WT_PAGE_ROW_LEAF: ret = __cursor_row_prev(cbt, newpage); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } if (ret != WT_NOTFOUND) break; diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c index 5ddddc5ff6e..b6172966eae 100644 --- a/src/third_party/wiredtiger/src/btree/bt_cursor.c +++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c @@ -915,17 +915,17 @@ __curfile_update_check(WT_CURSOR_BTREE *cbt) int __wt_btcur_insert_check(WT_CURSOR_BTREE *cbt) { - WT_BTREE *btree; WT_CURSOR *cursor; WT_DECL_RET; WT_SESSION_IMPL *session; uint64_t yield_count, sleep_usecs; cursor = &cbt->iface; - btree = cbt->btree; session = (WT_SESSION_IMPL *)cursor->session; yield_count = sleep_usecs = 0; + WT_ASSERT(session, cbt->btree->type == BTREE_ROW); + /* * The pinned page goes away if we do a search, get a local copy of any * pinned key and discard any pinned value. Unlike most of the btree @@ -936,14 +936,10 @@ __wt_btcur_insert_check(WT_CURSOR_BTREE *cbt) __cursor_novalue(cursor); retry: WT_ERR(__cursor_func_init(cbt, true)); + WT_ERR(__cursor_row_search(session, cbt, NULL, true)); - if (btree->type == BTREE_ROW) { - WT_ERR(__cursor_row_search(session, cbt, NULL, true)); - - /* Just check for conflicts. */ - ret = __curfile_update_check(cbt); - } else - WT_ERR(__wt_illegal_value(session, NULL)); + /* Just check for conflicts. */ + ret = __curfile_update_check(cbt); err: if (ret == WT_RESTART) { __cursor_restart(session, &yield_count, &sleep_usecs); @@ -1305,8 +1301,8 @@ done: switch (modify_type) { /* * WT_CURSOR.update returns a key and a value. */ - WT_TRET(__cursor_kv_return( - session, cbt, cbt->modify_update)); + ret = __cursor_kv_return( + session, cbt, cbt->modify_update); break; case WT_UPDATE_RESERVE: /* @@ -1319,13 +1315,11 @@ done: switch (modify_type) { * WT_CURSOR.modify has already created the return value * and our job is to leave it untouched. */ - WT_TRET(__wt_key_return(session, cbt)); + ret = __wt_key_return(session, cbt); break; case WT_UPDATE_BIRTHMARK: case WT_UPDATE_TOMBSTONE: - default: - WT_TRET(__wt_illegal_value(session, NULL)); - break; + WT_ILLEGAL_VALUE(session, modify_type); } } diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c index 16e25c1fe25..6eff8c53481 100644 --- a/src/third_party/wiredtiger/src/btree/bt_debug.c +++ b/src/third_party/wiredtiger/src/btree/bt_debug.c @@ -53,7 +53,7 @@ static int __debug_ref(WT_DBG *, WT_REF *); static int __debug_row_skip(WT_DBG *, WT_INSERT_HEAD *); static int __debug_tree(WT_SESSION_IMPL *, WT_REF *, const char *, uint32_t); static int __debug_update(WT_DBG *, WT_UPDATE *, bool); -static int __dmsg_wrapup(WT_DBG *); +static int __debug_wrapup(WT_DBG *); /* * __wt_debug_set_verbose -- @@ -270,7 +270,7 @@ __debug_config(WT_SESSION_IMPL *session, WT_DBG *ds, const char *ofile) ds->f = __dmsg_event; } else { if ((ds->fp = fopen(ofile, "w")) == NULL) - return (EIO); + return (__wt_set_return(session, EIO)); __wt_stream_set_line_buffer(ds->fp); ds->f = __dmsg_file; } @@ -282,12 +282,13 @@ __debug_config(WT_SESSION_IMPL *session, WT_DBG *ds, const char *ofile) } /* - * __dmsg_wrapup -- + * __debug_wrapup -- * Flush any remaining output, release resources. */ static int -__dmsg_wrapup(WT_DBG *ds) +__debug_wrapup(WT_DBG *ds) { + WT_DECL_RET; WT_ITEM *msg; WT_SESSION_IMPL *session; @@ -303,7 +304,7 @@ __dmsg_wrapup(WT_DBG *ds) */ if (msg != NULL) { if (msg->size != 0) - WT_RET(__wt_msg(session, "%s", (char *)msg->mem)); + ret = __wt_msg(session, "%s", (char *)msg->mem); __wt_scr_free(session, &ds->msg); } @@ -311,7 +312,7 @@ __dmsg_wrapup(WT_DBG *ds) if (ds->fp != NULL) (void)fclose(ds->fp); - return (0); + return (ret); } /* @@ -435,59 +436,61 @@ __wt_debug_disk( WT_SESSION_IMPL *session, const WT_PAGE_HEADER *dsk, const char *ofile) { WT_DBG *ds, _ds; + WT_DECL_RET; ds = &_ds; WT_RET(__debug_config(session, ds, ofile)); - WT_RET(ds->f(ds, "%s page", __wt_page_type_string(dsk->type))); + WT_ERR(ds->f(ds, "%s page", __wt_page_type_string(dsk->type))); switch (dsk->type) { case WT_PAGE_BLOCK_MANAGER: break; case WT_PAGE_COL_FIX: case WT_PAGE_COL_INT: case WT_PAGE_COL_VAR: - WT_RET(ds->f(ds, ", recno %" PRIu64, dsk->recno)); + WT_ERR(ds->f(ds, ", recno %" PRIu64, dsk->recno)); /* FALLTHROUGH */ case WT_PAGE_ROW_INT: case WT_PAGE_ROW_LEAF: - WT_RET(ds->f(ds, ", entries %" PRIu32, dsk->u.entries)); + WT_ERR(ds->f(ds, ", entries %" PRIu32, dsk->u.entries)); break; case WT_PAGE_OVFL: - WT_RET(ds->f(ds, ", datalen %" PRIu32, dsk->u.datalen)); + WT_ERR(ds->f(ds, ", datalen %" PRIu32, dsk->u.datalen)); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE_ERR(session, dsk->type); } if (F_ISSET(dsk, WT_PAGE_COMPRESSED)) - WT_RET(ds->f(ds, ", compressed")); + WT_ERR(ds->f(ds, ", compressed")); if (F_ISSET(dsk, WT_PAGE_ENCRYPTED)) - WT_RET(ds->f(ds, ", encrypted")); + WT_ERR(ds->f(ds, ", encrypted")); if (F_ISSET(dsk, WT_PAGE_EMPTY_V_ALL)) - WT_RET(ds->f(ds, ", empty-all")); + WT_ERR(ds->f(ds, ", empty-all")); if (F_ISSET(dsk, WT_PAGE_EMPTY_V_NONE)) - WT_RET(ds->f(ds, ", empty-none")); + WT_ERR(ds->f(ds, ", empty-none")); if (F_ISSET(dsk, WT_PAGE_LAS_UPDATE)) - WT_RET(ds->f(ds, ", LAS-update")); + WT_ERR(ds->f(ds, ", LAS-update")); - WT_RET(ds->f(ds, ", generation %" PRIu64 "\n", dsk->write_gen)); + WT_ERR(ds->f(ds, ", generation %" PRIu64 "\n", dsk->write_gen)); switch (dsk->type) { case WT_PAGE_BLOCK_MANAGER: break; case WT_PAGE_COL_FIX: - WT_RET(__debug_dsk_col_fix(ds, dsk)); + WT_ERR(__debug_dsk_col_fix(ds, dsk)); break; case WT_PAGE_COL_INT: case WT_PAGE_COL_VAR: case WT_PAGE_ROW_INT: case WT_PAGE_ROW_LEAF: - WT_RET(__debug_dsk_cell(ds, dsk)); + WT_ERR(__debug_dsk_cell(ds, dsk)); break; default: break; } - return (__dmsg_wrapup(ds)); +err: WT_TRET(__debug_wrapup(ds)); + return (ret); } /* @@ -620,9 +623,9 @@ __wt_debug_tree_shape( WT_WITH_PAGE_INDEX(session, ret = __debug_tree_shape_worker(ds, page, 1)); - WT_RET(ret); - return (__dmsg_wrapup(ds)); + WT_TRET(__debug_wrapup(ds)); + return (ret); } /* AUTOMATIC FLAG VALUE GENERATION START */ @@ -705,7 +708,7 @@ __wt_debug_page( WT_WITH_BTREE(session, btree, ret = __debug_page(ds, ref, WT_DEBUG_TREE_LEAF)); - WT_TRET(__dmsg_wrapup(ds)); + WT_TRET(__debug_wrapup(ds)); return (ret); } @@ -744,7 +747,7 @@ __debug_tree( ret = __debug_page(ds, ref, flags); - WT_TRET(__dmsg_wrapup(ds)); + WT_TRET(__debug_wrapup(ds)); return (ret); } @@ -788,7 +791,7 @@ __debug_page(WT_DBG *ds, WT_REF *ref, uint32_t flags) if (LF_ISSET(WT_DEBUG_TREE_LEAF)) WT_RET(__debug_page_row_leaf(ds, ref->page)); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, ref->page->type); } return (0); @@ -838,7 +841,7 @@ __debug_page_metadata(WT_DBG *ds, WT_REF *ref) case WT_PAGE_ROW_LEAF: entries = page->entries; break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, page->type); } WT_RET(ds->f(ds, ": %s\n", __wt_page_type_string(page->type))); @@ -878,7 +881,7 @@ __debug_page_metadata(WT_DBG *ds, WT_REF *ref) break; case 0: break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, mod->rec_result); } if (split_gen != 0) WT_RET(ds->f(ds, ", split-gen=%" PRIu64, split_gen)); @@ -1398,7 +1401,7 @@ __debug_cell_data(WT_DBG *ds, case WT_CELL_VALUE_SHORT: WT_ERR(__debug_item_value(ds, tag, buf->data, buf->size)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, unpack->raw); } err: __wt_scr_free(session, &buf); diff --git a/src/third_party/wiredtiger/src/btree/bt_delete.c b/src/third_party/wiredtiger/src/btree/bt_delete.c index a2f9afaf409..66127c0f0df 100644 --- a/src/third_party/wiredtiger/src/btree/bt_delete.c +++ b/src/third_party/wiredtiger/src/btree/bt_delete.c @@ -209,9 +209,7 @@ __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref) case WT_REF_LIMBO: case WT_REF_LOOKASIDE: case WT_REF_READING: - default: - return (__wt_illegal_value(session, - "illegal WT_REF.state rolling back deleted page")); + WT_ILLEGAL_VALUE(session, current_state); } if (locked) diff --git a/src/third_party/wiredtiger/src/btree/bt_discard.c b/src/third_party/wiredtiger/src/btree/bt_discard.c index d31f76f629c..0d49adc19ca 100644 --- a/src/third_party/wiredtiger/src/btree/bt_discard.c +++ b/src/third_party/wiredtiger/src/btree/bt_discard.c @@ -32,29 +32,14 @@ __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref) */ WT_ASSERT(session, S2BT(session)->evict_ref != ref); -#ifdef HAVE_DIAGNOSTIC - { - WT_HAZARD *hp; - int i; /* * Make sure no other thread has a hazard pointer on the page we are * about to discard. This is complicated by the fact that readers * publish their hazard pointer before re-checking the page state, so * our check can race with readers without indicating a real problem. - * Wait for up to a second for hazard pointers to be cleared. + * If we find a hazard pointer, wait for it to be cleared. */ - for (hp = NULL, i = 0; i < 100; i++) { - if ((hp = __wt_hazard_check(session, ref)) == NULL) - break; - __wt_sleep(0, 10000); - } - if (hp != NULL) - __wt_errx(session, - "discarded page has hazard pointer: (%p: %s, line %d)", - (void *)hp->ref, hp->file, hp->line); - WT_ASSERT(session, hp == NULL); - } -#endif + WT_ASSERT(session, __wt_hazard_check_assert(session, ref, true)); __wt_page_out(session, &ref->page); } @@ -263,6 +248,9 @@ __wt_free_ref( if (ref == NULL) return; + /* Assert there are no hazard pointers. */ + WT_ASSERT(session, __wt_hazard_check_assert(session, ref, false)); + /* * Optionally free the referenced pages. (The path to free referenced * page is used for error cleanup, no instantiated and then discarded diff --git a/src/third_party/wiredtiger/src/btree/bt_handle.c b/src/third_party/wiredtiger/src/btree/bt_handle.c index 9160ff1dd21..bcca39a1f17 100644 --- a/src/third_party/wiredtiger/src/btree/bt_handle.c +++ b/src/third_party/wiredtiger/src/btree/bt_handle.c @@ -447,6 +447,48 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) WT_RET(__wt_compressor_config(session, &cval, &btree->compressor)); /* + * Configure compression adjustment. + * When doing compression, assume compression rates that will result in + * pages larger than the maximum in-memory images allowed. If we're + * wrong, we adjust downward (but we're almost certainly correct, the + * maximum in-memory images allowed are only 4x the maximum page size, + * and compression always gives us more than 4x). + * Don't do compression adjustment for fixed-size column store, the + * leaf page sizes don't change. (We could adjust internal pages but not + * internal pages, but that seems an unlikely use case.) + * XXX + * Don't do compression adjustment of snappy-compressed blocks. + */ + btree->intlpage_compadjust = false; + btree->maxintlpage_precomp = btree->maxintlpage; + btree->leafpage_compadjust = false; + btree->maxleafpage_precomp = btree->maxleafpage; + if (btree->compressor != NULL && btree->compressor->compress != NULL && + !WT_STRING_MATCH("snappy", cval.str, cval.len) && + btree->type != BTREE_COL_FIX) { + /* + * Don't do compression adjustment when on-disk page sizes are + * less than 16KB. There's not enough compression going on to + * fine-tune the size, all we end up doing is hammering shared + * memory. + * + * Don't do compression adjustment when on-disk page sizes are + * equal to the maximum in-memory page image, the bytes taken + * for compression can't grow past the base value. + */ + if (btree->maxintlpage >= 16 * 1024 && + btree->maxmempage_image > btree->maxintlpage) { + btree->intlpage_compadjust = true; + btree->maxintlpage_precomp = btree->maxmempage_image; + } + if (btree->maxleafpage >= 16 * 1024 && + btree->maxmempage_image > btree->maxleafpage) { + btree->leafpage_compadjust = true; + btree->maxleafpage_precomp = btree->maxmempage_image; + } + } + + /* * We do not use __wt_config_gets_none here because "none" and the empty * string have different meanings. The empty string means inherit the * system encryption setting and "none" means this table is in the clear @@ -753,7 +795,7 @@ __btree_page_sizes(WT_SESSION_IMPL *session) WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; uint64_t cache_size; - uint32_t intl_split_size, leaf_split_size; + uint32_t intl_split_size, leaf_split_size, max; const char **cfg; btree = S2BT(session); @@ -787,6 +829,22 @@ __btree_page_sizes(WT_SESSION_IMPL *session) "size (%" PRIu32 "B)", btree->allocsize); /* + * Default in-memory page image size for compression is 4x the maximum + * internal or leaf page size, and enforce the on-disk page sizes as a + * lower-limit for the in-memory image size. + */ + WT_RET(__wt_config_gets(session, cfg, "memory_page_image_max", &cval)); + btree->maxmempage_image = (uint32_t)cval.val; + max = WT_MAX(btree->maxintlpage, btree->maxleafpage); + if (btree->maxmempage_image == 0) + btree->maxmempage_image = 4 * max; + else if (btree->maxmempage_image < max) + WT_RET_MSG(session, EINVAL, + "in-memory page image size must be larger than the maximum " + "page size (%" PRIu32 "B < %" PRIu32 "B)", + btree->maxmempage_image, max); + + /* * Don't let pages grow large compared to the cache size or we can end * up in a situation where nothing can be evicted. Make sure at least * 10 pages fit in cache when it is at the dirty trigger where threads @@ -811,7 +869,7 @@ __btree_page_sizes(WT_SESSION_IMPL *session) * size. This gives multi-threaded append workloads a better chance of * not stalling. */ - btree->splitmempage = 8 * btree->maxmempage / 10; + btree->splitmempage = (8 * btree->maxmempage) / 10; /* * Get the split percentage (reconciliation splits pages into smaller @@ -827,8 +885,10 @@ __btree_page_sizes(WT_SESSION_IMPL *session) "%d%%.", session->dhandle->name, WT_BTREE_MIN_SPLIT_PCT)); } else btree->split_pct = (int)cval.val; - intl_split_size = __wt_split_page_size(btree, btree->maxintlpage); - leaf_split_size = __wt_split_page_size(btree, btree->maxleafpage); + intl_split_size = __wt_split_page_size( + btree->split_pct, btree->maxintlpage, btree->allocsize); + leaf_split_size = __wt_split_page_size( + btree->split_pct, btree->maxleafpage, btree->allocsize); /* * In-memory split configuration. @@ -915,10 +975,11 @@ __wt_btree_immediately_durable(WT_SESSION_IMPL *session) /* * This is used to determine whether timestamp updates should - * be rolled back for this btree. It's likely that the particular - * test required here will change when rollback to stable is - * supported with in-memory configurations. + * be rolled back for this btree. With in-memory, the logging + * setting on tables is still important and when enabled they + * should be considered "durable". */ - return (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED) && + return ((FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED) || + (F_ISSET(S2C(session), WT_CONN_IN_MEMORY))) && !F_ISSET(btree, WT_BTREE_NO_LOGGING)); } diff --git a/src/third_party/wiredtiger/src/btree/bt_io.c b/src/third_party/wiredtiger/src/btree/bt_io.c index 1379553c211..eb4fdc2e0ae 100644 --- a/src/third_party/wiredtiger/src/btree/bt_io.c +++ b/src/third_party/wiredtiger/src/btree/bt_io.c @@ -153,10 +153,10 @@ corrupt: if (ret == 0) ret = WT_ERROR; if (!F_ISSET(btree, WT_BTREE_VERIFY) && !F_ISSET(session, WT_SESSION_QUIET_CORRUPT_FILE)) { - __wt_err(session, ret, "%s", fail_msg); WT_TRET(bm->corrupt(bm, session, addr, addr_size)); - WT_TRET( - __wt_illegal_value(session, btree->dhandle->name)); + WT_PANIC_ERR(session, ret, + "%s: fatal read error: %s", + btree->dhandle->name, fail_msg); } } @@ -172,7 +172,7 @@ err: __wt_scr_free(session, &tmp); */ int __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, - uint8_t *addr, size_t *addr_sizep, + uint8_t *addr, size_t *addr_sizep, size_t *compressed_sizep, bool checkpoint, bool checkpoint_io, bool compressed) { WT_BM *bm; @@ -189,6 +189,9 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, int compression_failed; /* Extension API, so not a bool. */ bool data_checksum, encrypted, timer; + if (compressed_sizep != NULL) + *compressed_sizep = 0; + btree = S2BT(session); bm = btree->bm; encrypted = false; @@ -306,6 +309,10 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, memcpy(ctmp->mem, buf->mem, WT_BLOCK_COMPRESS_SKIP); ctmp->size = result_len; ip = ctmp; + + /* Optionally return the compressed size. */ + if (compressed_sizep != NULL) + *compressed_sizep = result_len; } } /* diff --git a/src/third_party/wiredtiger/src/btree/bt_ovfl.c b/src/third_party/wiredtiger/src/btree/bt_ovfl.c index ce0ee706923..6032364fff7 100644 --- a/src/third_party/wiredtiger/src/btree/bt_ovfl.c +++ b/src/third_party/wiredtiger/src/btree/bt_ovfl.c @@ -241,7 +241,7 @@ __wt_ovfl_discard(WT_SESSION_IMPL *session, WT_CELL *cell) __wt_cell_type_reset(session, unpack->cell, WT_CELL_VALUE_OVFL, WT_CELL_VALUE_OVFL_RM); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, unpack->raw); } __wt_writeunlock(session, &btree->ovfl_lock); diff --git a/src/third_party/wiredtiger/src/btree/bt_page.c b/src/third_party/wiredtiger/src/btree/bt_page.c index 612540956b7..e3f5d64deb9 100644 --- a/src/third_party/wiredtiger/src/btree/bt_page.c +++ b/src/third_party/wiredtiger/src/btree/bt_page.c @@ -57,7 +57,7 @@ __wt_page_alloc(WT_SESSION_IMPL *session, */ size += alloc_entries * sizeof(WT_ROW); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, type); } WT_RET(__wt_calloc(session, 1, size, &page)); @@ -112,7 +112,7 @@ err: if ((pindex = WT_INTL_INDEX_GET_SAFE(page)) != NULL) { NULL : (WT_ROW *)((uint8_t *)page + sizeof(WT_PAGE)); page->entries = alloc_entries; break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, type); } /* Increment the cache statistics. */ @@ -186,7 +186,7 @@ __wt_page_inmem(WT_SESSION_IMPL *session, WT_RET(__inmem_row_leaf_entries( session, dsk, &alloc_entries)); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, dsk->type); } /* Allocate and initialize a new WT_PAGE. */ @@ -222,7 +222,7 @@ __wt_page_inmem(WT_SESSION_IMPL *session, case WT_PAGE_ROW_LEAF: WT_ERR(__inmem_row_leaf(session, page)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } /* Update the page's cache statistics. */ @@ -503,7 +503,7 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) ref->addr = cell; ++refp; break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, unpack->type); } } @@ -556,7 +556,7 @@ __inmem_row_leaf_entries( case WT_CELL_VALUE: case WT_CELL_VALUE_OVFL: break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, unpack->type); } } @@ -614,7 +614,7 @@ __inmem_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page) break; case WT_CELL_VALUE_OVFL: break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, unpack->type); } } diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index c8368624d3c..58853bff6ac 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -221,7 +221,7 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) WT_ERR(__wt_buf_set(session, current_key, las_key.data, las_key.size)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } /* Append the latest update to the list. */ @@ -251,7 +251,7 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref) current_key, ref, &cbt, first_upd)); first_upd = NULL; break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, page->type); } /* Discard the cursor. */ @@ -788,7 +788,7 @@ skip_evict: /* return (LF_ISSET(WT_READ_IGNORE_CACHE_SIZE) && !F_ISSET(session, WT_SESSION_IGNORE_CACHE_SIZE) ? 0 : __wt_txn_autocommit_check(session)); - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, current_state); } /* diff --git a/src/third_party/wiredtiger/src/btree/bt_rebalance.c b/src/third_party/wiredtiger/src/btree/bt_rebalance.c index 17adcdd6da6..a509bbb88bc 100644 --- a/src/third_party/wiredtiger/src/btree/bt_rebalance.c +++ b/src/third_party/wiredtiger/src/btree/bt_rebalance.c @@ -235,7 +235,7 @@ __rebalance_col_walk( unpack.type == WT_CELL_ADDR_LEAF ? WT_ADDR_LEAF : WT_ADDR_LEAF_NO, rs)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, unpack.type); } } @@ -386,7 +386,7 @@ __rebalance_row_walk( first_cell = false; break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, unpack.type); } } @@ -440,7 +440,7 @@ __wt_bt_rebalance(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR( __rebalance_col_walk(session, btree->root.page->dsk, rs)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, rs->type); } /* Build a new root page. */ diff --git a/src/third_party/wiredtiger/src/btree/bt_slvg.c b/src/third_party/wiredtiger/src/btree/bt_slvg.c index 54f4eaa8f52..afb1657406a 100644 --- a/src/third_party/wiredtiger/src/btree/bt_slvg.c +++ b/src/third_party/wiredtiger/src/btree/bt_slvg.c @@ -1770,7 +1770,8 @@ __slvg_row_trk_update_start( * would have discarded it, we wouldn't be here. Therefore, this test * is safe. (But, it never hurts to check.) */ - WT_ERR_TEST(!found, WT_ERROR); + if (!found) + WT_ERR_MSG(session, WT_ERROR, "expected on-page key not found"); WT_ERR(__slvg_key_copy(session, &trk->row_start, key)); /* @@ -2350,7 +2351,7 @@ __slvg_ovfl_ref(WT_SESSION_IMPL *session, WT_TRACK *trk, bool multi_panic) { if (F_ISSET(trk, WT_TRACK_OVFL_REFD)) { if (!multi_panic) - return (EBUSY); + return (__wt_set_return(session, EBUSY)); WT_PANIC_RET(session, EINVAL, "overflow record unexpectedly referenced multiple times " "during leaf page merge"); diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index a98de6c6c9f..1b4c16a8e1d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -287,7 +287,7 @@ __split_ref_move(WT_SESSION_IMPL *session, WT_PAGE *from_home, case WT_CELL_ADDR_LEAF_NO: addr->type = WT_ADDR_LEAF_NO; break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, unpack.raw); } if (__wt_atomic_cas_ptr(&ref->addr, ref_addr, addr)) addr = NULL; @@ -449,7 +449,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root) children = pindex->entries / btree->split_deepen_per_child; if (children < 10) { if (pindex->entries < 100) - return (EBUSY); + return (__wt_set_return(session, EBUSY)); children = 10; } chunk = pindex->entries / children; @@ -872,6 +872,8 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, /* Free the backing block and address. */ WT_TRET(__wt_ref_block_free(session, next_ref)); + WT_ASSERT(session, + __wt_hazard_check_assert(session, next_ref, false)); WT_TRET(__split_safe_free( session, split_gen, exclusive, next_ref, sizeof(WT_REF))); parent_decr += sizeof(WT_REF); @@ -915,7 +917,7 @@ err: __wt_scr_free(session, &scr); * being deleted, but don't be noisy, there's nothing wrong. */ if (empty_parent) - ret = EBUSY; + ret = __wt_set_return(session, EBUSY); break; case WT_ERR_PANIC: __wt_err(session, ret, "fatal error during parent page split"); @@ -982,7 +984,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page) children = pindex->entries / btree->split_deepen_per_child; if (children < 10) { if (pindex->entries < 100) - return (EBUSY); + return (__wt_set_return(session, EBUSY)); children = 10; } chunk = pindex->entries / children; @@ -1214,7 +1216,7 @@ __split_internal_lock( * the parent, give up to avoid that deadlock. */ if (!trylock && !__wt_btree_can_evict_dirty(session)) - return (EBUSY); + return (__wt_set_return(session, EBUSY)); /* * Get a page-level lock on the parent to single-thread splits into the @@ -1511,7 +1513,7 @@ __split_multi_inmem( WT_ERR(__wt_row_modify(session, &cbt, key, NULL, upd, WT_UPDATE_INVALID, true)); break; - WT_ILLEGAL_VALUE_ERR(session); + WT_ILLEGAL_VALUE_ERR(session, orig->type); } } diff --git a/src/third_party/wiredtiger/src/btree/bt_stat.c b/src/third_party/wiredtiger/src/btree/bt_stat.c index 0fbd5ce869f..2fd23596cd7 100644 --- a/src/third_party/wiredtiger/src/btree/bt_stat.c +++ b/src/third_party/wiredtiger/src/btree/bt_stat.c @@ -122,7 +122,7 @@ __stat_page(WT_SESSION_IMPL *session, WT_PAGE *page, WT_DSRC_STATS **stats) case WT_PAGE_ROW_LEAF: __stat_page_row_leaf(session, page, stats); break; - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, page->type); } return (0); } diff --git a/src/third_party/wiredtiger/src/btree/bt_sync.c b/src/third_party/wiredtiger/src/btree/bt_sync.c index 24eea097cdf..fee6f534321 100644 --- a/src/third_party/wiredtiger/src/btree/bt_sync.c +++ b/src/third_party/wiredtiger/src/btree/bt_sync.c @@ -354,7 +354,7 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop) break; case WT_SYNC_CLOSE: case WT_SYNC_DISCARD: - WT_ERR(__wt_illegal_value(session, NULL)); + WT_ERR(__wt_illegal_value(session, syncop)); break; } diff --git a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c index aae50ed636c..727a8e5b1a7 100644 --- a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c +++ b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c @@ -166,7 +166,7 @@ __wt_verify_dsk_image(WT_SESSION_IMPL *session, case WT_PAGE_BLOCK_MANAGER: case WT_PAGE_OVFL: return (__verify_dsk_chunk(session, tag, dsk, dsk->u.datalen)); - WT_ILLEGAL_VALUE(session); + WT_ILLEGAL_VALUE(session, dsk->type); } /* NOTREACHED */ } diff --git a/src/third_party/wiredtiger/src/btree/bt_walk.c b/src/third_party/wiredtiger/src/btree/bt_walk.c index a2386d907c7..6434142824e 100644 --- a/src/third_party/wiredtiger/src/btree/bt_walk.c +++ b/src/third_party/wiredtiger/src/btree/bt_walk.c @@ -414,24 +414,41 @@ restart: /* empty_internal = false; } - /* - * Optionally return internal pages. Swap our previous - * hazard pointer for the page we'll return. We don't - * handle restart or not-found returns, it would require - * additional complexity and is not a possible return: - * we're moving to the parent of the current child page, - * the parent can't have been evicted. - */ - if (!LF_ISSET(WT_READ_SKIP_INTL)) { - WT_ERR(__wt_page_swap( - session, couple, ref, flags)); - couple = NULL; - *refp = ref; - goto done; - } - /* Encourage races. */ __wt_timing_stress(session, WT_TIMING_STRESS_SPLIT_8); + + /* Optionally return internal pages. */ + if (LF_ISSET(WT_READ_SKIP_INTL)) + continue; + + for (;;) { + /* + * Swap our previous hazard pointer for the page + * we'll return. + * + * Not-found is an expected return, as eviction + * might have been attempted. The page can't be + * evicted, we're holding a hazard pointer on a + * child, spin until we're successful. + * + * Restart is not expected, our parent WT_REF + * should not have split. + */ + ret = __wt_page_swap(session, + couple, ref, WT_READ_NOTFOUND_OK | flags); + if (ret == 0) { + /* Success, "couple" released. */ + couple = NULL; + *refp = ref; + goto done; + } + + WT_ASSERT(session, ret == WT_NOTFOUND); + WT_ERR_NOTFOUND_OK(ret); + + __wt_spin_backoff(&yield_count, &sleep_usecs); + } + /* NOTREACHED */ } if (prev) diff --git a/src/third_party/wiredtiger/src/btree/col_srch.c b/src/third_party/wiredtiger/src/btree/col_srch.c index 123b640cdf4..4b7b3d3d727 100644 --- a/src/third_party/wiredtiger/src/btree/col_srch.c +++ b/src/third_party/wiredtiger/src/btree/col_srch.c @@ -180,7 +180,7 @@ descend: /* } /* Encourage races. */ - __wt_timing_stress(session, WT_TIMING_STRESS_SPLIT_9); + WT_DIAGNOSTIC_YIELD; /* * Swap the current page for the child page. If the page splits diff --git a/src/third_party/wiredtiger/src/btree/row_srch.c b/src/third_party/wiredtiger/src/btree/row_srch.c index a3f05a2700f..38921471d74 100644 --- a/src/third_party/wiredtiger/src/btree/row_srch.c +++ b/src/third_party/wiredtiger/src/btree/row_srch.c @@ -432,7 +432,7 @@ append: if (__wt_split_descent_race( } descend: /* Encourage races. */ - __wt_timing_stress(session, WT_TIMING_STRESS_SPLIT_9); + WT_DIAGNOSTIC_YIELD; /* * Swap the current page for the child page. If the page splits |