From 7c8c1f8d508f62aeb3dbc1ac093330fb5a872174 Mon Sep 17 00:00:00 2001 From: Alex Gorrod Date: Wed, 30 Sep 2015 15:04:43 +1000 Subject: Import wiredtiger-wiredtiger-2.6.1-1261-g3c85664.tar.gz from wiredtiger branch mongodb-3.2 --- src/third_party/wiredtiger/dist/s_string.ok | 1 + src/third_party/wiredtiger/dist/s_whitespace | 9 ++- src/third_party/wiredtiger/src/block/block_ckpt.c | 4 +- src/third_party/wiredtiger/src/btree/bt_compact.c | 2 +- src/third_party/wiredtiger/src/btree/bt_debug.c | 2 + src/third_party/wiredtiger/src/btree/bt_handle.c | 4 +- src/third_party/wiredtiger/src/btree/bt_page.c | 17 +++++- src/third_party/wiredtiger/src/btree/bt_read.c | 10 ++-- src/third_party/wiredtiger/src/btree/bt_split.c | 4 ++ src/third_party/wiredtiger/src/conn/conn_api.c | 2 +- src/third_party/wiredtiger/src/conn/conn_ckpt.c | 6 +- src/third_party/wiredtiger/src/conn/conn_log.c | 35 +++++++++--- src/third_party/wiredtiger/src/conn/conn_stat.c | 6 +- src/third_party/wiredtiger/src/cursor/cur_backup.c | 4 +- src/third_party/wiredtiger/src/cursor/cur_stat.c | 16 +++--- src/third_party/wiredtiger/src/evict/evict_file.c | 2 +- src/third_party/wiredtiger/src/evict/evict_lru.c | 6 +- src/third_party/wiredtiger/src/evict/evict_page.c | 2 +- src/third_party/wiredtiger/src/include/api.h | 4 +- src/third_party/wiredtiger/src/include/block.h | 2 +- src/third_party/wiredtiger/src/include/btmem.h | 7 +-- src/third_party/wiredtiger/src/include/btree.h | 6 +- src/third_party/wiredtiger/src/include/btree.i | 16 +++--- .../wiredtiger/src/include/connection.h | 16 +++--- src/third_party/wiredtiger/src/include/cursor.h | 6 +- src/third_party/wiredtiger/src/include/intpack.i | 4 +- src/third_party/wiredtiger/src/include/os.h | 2 +- src/third_party/wiredtiger/src/include/schema.h | 66 +++++++++++----------- src/third_party/wiredtiger/src/include/session.h | 2 +- src/third_party/wiredtiger/src/include/txn.h | 2 +- src/third_party/wiredtiger/src/log/log.c | 26 +++------ src/third_party/wiredtiger/src/log/log_slot.c | 12 +++- src/third_party/wiredtiger/src/lsm/lsm_work_unit.c | 2 +- src/third_party/wiredtiger/src/meta/meta_track.c | 62 ++++++++------------ .../wiredtiger/src/os_posix/os_fallocate.c | 12 ++-- .../wiredtiger/src/os_win/os_fallocate.c | 2 +- .../wiredtiger/src/reconcile/rec_write.c | 36 ++++++------ .../wiredtiger/src/session/session_api.c | 7 +++ .../wiredtiger/src/session/session_compact.c | 2 +- src/third_party/wiredtiger/src/support/huffman.c | 10 ++++ src/third_party/wiredtiger/src/txn/txn_log.c | 4 +- 41 files changed, 242 insertions(+), 198 deletions(-) diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index bfc4124f74d..021e222919e 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -842,6 +842,7 @@ rectype recurse refp reinitialization +relocked resize resizing ret diff --git a/src/third_party/wiredtiger/dist/s_whitespace b/src/third_party/wiredtiger/dist/s_whitespace index dfc031e3ea4..38eb5d6c2df 100755 --- a/src/third_party/wiredtiger/dist/s_whitespace +++ b/src/third_party/wiredtiger/dist/s_whitespace @@ -4,15 +4,18 @@ t=__wt.$$ trap 'rm -f $t; exit 0' 0 1 2 3 13 15 -# Clear lines that only contain whitespace. +# Clear lines that only contain whitespace, discard trailing empty lines. whitespace() { - sed -e 's/[ ][ ]*$//' < $1 > $t + sed -e 's/[ ][ ]*$//' \ + -e '${' \ + -e '/^$/d' \ + -e '}' < $1 > $t cmp $t $1 > /dev/null 2>&1 || (echo "$1" && cp $t $1) } # Clear lines that only contain whitespace, compress multiple empty lines -# into a single line, discarding trailing empty lines. +# into a single line, discard trailing empty lines. whitespace_and_empty_line() { sed -e 's/[ ][ ]*$//' \ diff --git a/src/third_party/wiredtiger/src/block/block_ckpt.c b/src/third_party/wiredtiger/src/block/block_ckpt.c index a23b95233e1..9b42a072d73 100644 --- a/src/third_party/wiredtiger/src/block/block_ckpt.c +++ b/src/third_party/wiredtiger/src/block/block_ckpt.c @@ -657,7 +657,7 @@ live_update: } #endif - block->ckpt_inprogress = 1; + block->ckpt_inprogress = true; err: if (locked) __wt_spin_unlock(session, &block->live_lock); @@ -775,7 +775,7 @@ __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_RET_MSG(session, WT_ERROR, "%s: checkpoint resolved, but no checkpoint in progress", block->name); - block->ckpt_inprogress = 0; + block->ckpt_inprogress = false; __wt_spin_lock(session, &block->live_lock); ret = __wt_block_extlist_merge( diff --git a/src/third_party/wiredtiger/src/btree/bt_compact.c b/src/third_party/wiredtiger/src/btree/bt_compact.c index f7997d8b909..18b6860c758 100644 --- a/src/third_party/wiredtiger/src/btree/bt_compact.c +++ b/src/third_party/wiredtiger/src/btree/bt_compact.c @@ -137,7 +137,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) if (skip) continue; - session->compaction = 1; + session->compaction = true; /* Rewrite the page: mark the page and tree dirty. */ WT_ERR(__wt_page_modify_init(session, ref->page)); __wt_page_modify_set(session, ref->page); diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c index 4d3add47052..ee2898f60be 100644 --- a/src/third_party/wiredtiger/src/btree/bt_debug.c +++ b/src/third_party/wiredtiger/src/btree/bt_debug.c @@ -645,6 +645,8 @@ __debug_page_metadata(WT_DBG *ds, WT_PAGE *page) __dmsg(ds, ", disk-mapped"); if (F_ISSET_ATOMIC(page, WT_PAGE_EVICT_LRU)) __dmsg(ds, ", evict-lru"); + if (F_ISSET_ATOMIC(page, WT_PAGE_OVERFLOW_KEYS)) + __dmsg(ds, ", overflow-keys"); if (F_ISSET_ATOMIC(page, WT_PAGE_RECONCILIATION)) __dmsg(ds, ", reconciliation"); if (F_ISSET_ATOMIC(page, WT_PAGE_SPLIT_INSERT)) diff --git a/src/third_party/wiredtiger/src/btree/bt_handle.c b/src/third_party/wiredtiger/src/btree/bt_handle.c index 9187c72ae8d..3e611a107ab 100644 --- a/src/third_party/wiredtiger/src/btree/bt_handle.c +++ b/src/third_party/wiredtiger/src/btree/bt_handle.c @@ -293,11 +293,11 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) case BTREE_ROW: WT_RET(__wt_config_gets( session, cfg, "internal_key_truncate", &cval)); - btree->internal_key_truncate = cval.val == 0 ? 0 : 1; + btree->internal_key_truncate = cval.val != 0; WT_RET(__wt_config_gets( session, cfg, "prefix_compression", &cval)); - btree->prefix_compression = cval.val == 0 ? 0 : 1; + btree->prefix_compression = cval.val != 0; WT_RET(__wt_config_gets( session, cfg, "prefix_compression_min", &cval)); btree->prefix_compression_min = (u_int)cval.val; diff --git a/src/third_party/wiredtiger/src/btree/bt_page.c b/src/third_party/wiredtiger/src/btree/bt_page.c index 34964def54c..8808f0b1a85 100644 --- a/src/third_party/wiredtiger/src/btree/bt_page.c +++ b/src/third_party/wiredtiger/src/btree/bt_page.c @@ -405,6 +405,7 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) WT_PAGE_INDEX *pindex; WT_REF *ref, **refp; uint32_t i; + bool overflow_keys; btree = S2BT(session); unpack = &_unpack; @@ -419,6 +420,7 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) */ pindex = WT_INTL_INDEX_GET_SAFE(page); refp = pindex->index; + overflow_keys = false; WT_CELL_FOREACH(btree, dsk, cell, unpack, i) { ref = *refp; ref->home = page; @@ -433,7 +435,12 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) __wt_ref_key_onpage_set(page, ref, unpack); break; case WT_CELL_KEY_OVFL: - /* Instantiate any overflow records. */ + /* + * Instantiate any overflow keys; WiredTiger depends on + * this, assuming any overflow key is instantiated, and + * any keys that aren't instantiated cannot be overflow + * items. + */ WT_ERR(__wt_dsk_cell_data_ref( session, page->type, unpack, current)); @@ -442,6 +449,7 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) current->data, current->size, ref)); *sizep += sizeof(WT_IKEY) + current->size; + overflow_keys = true; break; case WT_CELL_ADDR_DEL: /* @@ -487,6 +495,13 @@ __inmem_row_int(WT_SESSION_IMPL *session, WT_PAGE *page, size_t *sizep) } } + /* + * We track if an internal page has backing overflow keys, as overflow + * keys limit the eviction we can do during a checkpoint. + */ + if (overflow_keys) + F_SET_ATOMIC(page, WT_PAGE_OVERFLOW_KEYS); + err: __wt_scr_free(session, ¤t); return (ret); } diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index 96df838429a..d9cdfc78c75 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -283,11 +283,13 @@ err: WT_TRET(__wt_las_cursor_close(session, &cursor, session_flags)); * Check if a page matches the criteria for forced eviction. */ static int -__evict_force_check(WT_SESSION_IMPL *session, WT_PAGE *page) +__evict_force_check(WT_SESSION_IMPL *session, WT_REF *ref) { WT_BTREE *btree; + WT_PAGE *page; btree = S2BT(session); + page = ref->page; /* Pages are usually small enough, check that first. */ if (page->memory_footprint < btree->maxmempage) @@ -311,7 +313,7 @@ __evict_force_check(WT_SESSION_IMPL *session, WT_PAGE *page) __wt_txn_update_oldest(session, false); /* If eviction cannot succeed, don't try. */ - return (__wt_page_can_evict(session, page, true, NULL)); + return (__wt_page_can_evict(session, ref, true, NULL)); } /* @@ -524,9 +526,8 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags /* * Forcibly evict pages that are too big. */ - page = ref->page; if (force_attempts < 10 && - __evict_force_check(session, page)) { + __evict_force_check(session, ref)) { ++force_attempts; ret = __wt_page_release_evict(session, ref); /* If forced eviction fails, stall. */ @@ -556,6 +557,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags * * Otherwise, update the page's read generation. */ + page = ref->page; if (oldgen && page->read_gen == WT_READGEN_NOTSET) __wt_page_evict_soon(page); else if (!LF_ISSET(WT_READ_NO_GEN) && diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index dba0b7883a0..29153ced178 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -229,6 +229,10 @@ __split_ovfl_key_cleanup(WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref) WT_IKEY *ikey; uint32_t cell_offset; + /* There's a per-page flag if there are any overflow keys at all. */ + if (!F_ISSET_ATOMIC(page, WT_PAGE_OVERFLOW_KEYS)) + return (0); + /* * A key being discarded (page split) or moved to a different page (page * deepening) may be an on-page overflow key. Clear any reference to an diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c index 376ed0e99ee..b5d0e8f2883 100644 --- a/src/third_party/wiredtiger/src/conn/conn_api.c +++ b/src/third_party/wiredtiger/src/conn/conn_api.c @@ -1967,7 +1967,7 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, } WT_ERR(__wt_config_gets(session, cfg, "mmap", &cval)); - conn->mmap = cval.val == 0 ? 0 : 1; + conn->mmap = cval.val != 0; WT_ERR(__conn_statistics_config(session, cfg)); WT_ERR(__wt_lsm_manager_config(session, cfg)); diff --git a/src/third_party/wiredtiger/src/conn/conn_ckpt.c b/src/third_party/wiredtiger/src/conn/conn_ckpt.c index 6598c567de9..7fc790d5efa 100644 --- a/src/third_party/wiredtiger/src/conn/conn_ckpt.c +++ b/src/third_party/wiredtiger/src/conn/conn_ckpt.c @@ -148,7 +148,7 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn) */ WT_RET(__wt_thread_create( session, &conn->ckpt_tid, __ckpt_server, session)); - conn->ckpt_tid_set = 1; + conn->ckpt_tid_set = true; return (0); } @@ -194,7 +194,7 @@ __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session) if (conn->ckpt_tid_set) { WT_TRET(__wt_cond_signal(session, conn->ckpt_cond)); WT_TRET(__wt_thread_join(session, conn->ckpt_tid)); - conn->ckpt_tid_set = 0; + conn->ckpt_tid_set = false; } WT_TRET(__wt_cond_destroy(session, &conn->ckpt_cond)); @@ -211,7 +211,7 @@ __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session) * get confused. */ conn->ckpt_session = NULL; - conn->ckpt_tid_set = 0; + conn->ckpt_tid_set = false; conn->ckpt_cond = NULL; conn->ckpt_config = NULL; conn->ckpt_usecs = 0; diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index fee914d8986..eba0a2769d6 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -142,7 +142,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) */ WT_RET(__wt_readlock(session, conn->hot_backup_lock)); locked = true; - if (conn->hot_backup == 0 || backup_file != 0) { + if (!conn->hot_backup || backup_file != 0) { for (i = 0; i < logcount; i++) { WT_ERR(__wt_log_extract_lognum( session, logfiles[i], &lognum)); @@ -363,8 +363,23 @@ __log_file_server(void *arg) * We have to wait until the LSN we asked for is * written. If it isn't signal the wrlsn thread * to get it written. + * + * We also have to wait for the written LSN and the + * sync LSN to be in the same file so that we know we + * have synchronized all earlier log files. */ if (__wt_log_cmp(&log->bg_sync_lsn, &min_lsn) <= 0) { + /* + * If the sync file is behind either the one + * wanted for a background sync or the write LSN + * has moved to another file continue to let + * this worker thread process that older file + * immediately. + */ + if ((log->sync_lsn.file < + log->bg_sync_lsn.file) || + (log->sync_lsn.file < min_lsn.file)) + continue; WT_ERR(__wt_fsync(session, log->log_fh)); __wt_spin_lock(session, &log->log_sync_lock); locked = true; @@ -374,6 +389,8 @@ __log_file_server(void *arg) */ if (__wt_log_cmp( &log->sync_lsn, &min_lsn) <= 0) { + WT_ASSERT(session, + min_lsn.file == log->sync_lsn.file); log->sync_lsn = min_lsn; WT_ERR(__wt_cond_signal( session, log->log_sync_cond)); @@ -395,7 +412,7 @@ __log_file_server(void *arg) } /* Wait until the next event. */ WT_ERR(__wt_cond_wait( - session, conn->log_file_cond, WT_MILLION)); + session, conn->log_file_cond, WT_MILLION / 10)); } if (0) { @@ -781,7 +798,7 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) */ WT_RET(__wt_thread_create(conn->log_file_session, &conn->log_file_tid, __log_file_server, conn->log_file_session)); - conn->log_file_tid_set = 1; + conn->log_file_tid_set = true; /* * Start the log write LSN thread. It is not configurable. @@ -793,7 +810,7 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) "log write lsn server", false, &conn->log_wrlsn_cond)); WT_RET(__wt_thread_create(conn->log_wrlsn_session, &conn->log_wrlsn_tid, __log_wrlsn_server, conn->log_wrlsn_session)); - conn->log_wrlsn_tid_set = 1; + conn->log_wrlsn_tid_set = true; /* If no log thread services are configured, we're done. */ if (!FLD_ISSET(conn->log_flags, @@ -808,7 +825,7 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) */ if (conn->log_session != NULL) { WT_ASSERT(session, conn->log_cond != NULL); - WT_ASSERT(session, conn->log_tid_set != 0); + WT_ASSERT(session, conn->log_tid_set == true); WT_RET(__wt_cond_signal(session, conn->log_cond)); } else { /* The log server gets its own session. */ @@ -822,7 +839,7 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) */ WT_RET(__wt_thread_create(conn->log_session, &conn->log_tid, __log_server, conn->log_session)); - conn->log_tid_set = 1; + conn->log_tid_set = true; } return (0); @@ -853,12 +870,12 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session) if (conn->log_tid_set) { WT_TRET(__wt_cond_signal(session, conn->log_cond)); WT_TRET(__wt_thread_join(session, conn->log_tid)); - conn->log_tid_set = 0; + conn->log_tid_set = false; } if (conn->log_file_tid_set) { WT_TRET(__wt_cond_signal(session, conn->log_file_cond)); WT_TRET(__wt_thread_join(session, conn->log_file_tid)); - conn->log_file_tid_set = 0; + conn->log_file_tid_set = false; } if (conn->log_file_session != NULL) { wt_session = &conn->log_file_session->iface; @@ -868,7 +885,7 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session) if (conn->log_wrlsn_tid_set) { WT_TRET(__wt_cond_signal(session, conn->log_wrlsn_cond)); WT_TRET(__wt_thread_join(session, conn->log_wrlsn_tid)); - conn->log_wrlsn_tid_set = 0; + conn->log_wrlsn_tid_set = false; } if (conn->log_wrlsn_session != NULL) { wt_session = &conn->log_wrlsn_session->iface; diff --git a/src/third_party/wiredtiger/src/conn/conn_stat.c b/src/third_party/wiredtiger/src/conn/conn_stat.c index 44366e866f4..d8c7227ae61 100644 --- a/src/third_party/wiredtiger/src/conn/conn_stat.c +++ b/src/third_party/wiredtiger/src/conn/conn_stat.c @@ -467,7 +467,7 @@ __statlog_start(WT_CONNECTION_IMPL *conn) */ WT_RET(__wt_thread_create( session, &conn->stat_tid, __statlog_server, session)); - conn->stat_tid_set = 1; + conn->stat_tid_set = true; return (0); } @@ -517,7 +517,7 @@ __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close) if (conn->stat_tid_set) { WT_TRET(__wt_cond_signal(session, conn->stat_cond)); WT_TRET(__wt_thread_join(session, conn->stat_tid)); - conn->stat_tid_set = 0; + conn->stat_tid_set = false; } /* Log a set of statistics on shutdown if configured. */ @@ -538,7 +538,7 @@ __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close) /* Clear connection settings so reconfigure is reliable. */ conn->stat_session = NULL; - conn->stat_tid_set = 0; + conn->stat_tid_set = false; conn->stat_format = NULL; WT_TRET(__wt_fclose(&conn->stat_fp, WT_FHANDLE_APPEND)); conn->stat_path = NULL; diff --git a/src/third_party/wiredtiger/src/cursor/cur_backup.c b/src/third_party/wiredtiger/src/cursor/cur_backup.c index c971ed6fb75..6f7d492327b 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_backup.c +++ b/src/third_party/wiredtiger/src/cursor/cur_backup.c @@ -218,7 +218,7 @@ __backup_start( * checkpoint. */ WT_RET(__wt_writelock(session, conn->hot_backup_lock)); - conn->hot_backup = 1; + conn->hot_backup = true; WT_ERR(__wt_writeunlock(session, conn->hot_backup_lock)); /* Create the hot backup file. */ @@ -319,7 +319,7 @@ __backup_stop(WT_SESSION_IMPL *session) /* Checkpoint deletion can proceed, as can the next hot backup. */ WT_TRET(__wt_writelock(session, conn->hot_backup_lock)); - conn->hot_backup = 0; + conn->hot_backup = false; WT_TRET(__wt_writeunlock(session, conn->hot_backup_lock)); return (ret); diff --git a/src/third_party/wiredtiger/src/cursor/cur_stat.c b/src/third_party/wiredtiger/src/cursor/cur_stat.c index 2216a1d969d..81d028c165a 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_stat.c +++ b/src/third_party/wiredtiger/src/cursor/cur_stat.c @@ -202,12 +202,12 @@ __curstat_next(WT_CURSOR *cursor) if (cst->notinitialized) { WT_ERR(__wt_curstat_init( session, cursor->internal_uri, cst->cfg, cst)); - cst->notinitialized = 0; + cst->notinitialized = false; } /* Move to the next item. */ if (cst->notpositioned) { - cst->notpositioned = 0; + cst->notpositioned = false; cst->key = WT_STAT_KEY_MIN(cst); } else if (cst->key < WT_STAT_KEY_MAX(cst)) ++cst->key; @@ -240,12 +240,12 @@ __curstat_prev(WT_CURSOR *cursor) if (cst->notinitialized) { WT_ERR(__wt_curstat_init( session, cursor->internal_uri, cst->cfg, cst)); - cst->notinitialized = 0; + cst->notinitialized = false; } /* Move to the previous item. */ if (cst->notpositioned) { - cst->notpositioned = 0; + cst->notpositioned = false; cst->key = WT_STAT_KEY_MAX(cst); } else if (cst->key > WT_STAT_KEY_MIN(cst)) --cst->key; @@ -275,7 +275,7 @@ __curstat_reset(WT_CURSOR *cursor) cst = (WT_CURSOR_STAT *)cursor; CURSOR_API_CALL(cursor, session, reset, NULL); - cst->notinitialized = cst->notpositioned = 1; + cst->notinitialized = cst->notpositioned = true; F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); err: API_END_RET(session, ret); @@ -302,7 +302,7 @@ __curstat_search(WT_CURSOR *cursor) if (cst->notinitialized) { WT_ERR(__wt_curstat_init( session, cursor->internal_uri, cst->cfg, cst)); - cst->notinitialized = 0; + cst->notinitialized = false; } if (cst->key < WT_STAT_KEY_MIN(cst) || cst->key > WT_STAT_KEY_MAX(cst)) @@ -582,10 +582,10 @@ __wt_curstat_open(WT_SESSION_IMPL *session, * the open returns. */ WT_ERR(__wt_curstat_init(session, uri, cst->cfg, cst)); - cst->notinitialized = 0; + cst->notinitialized = false; /* The cursor isn't yet positioned. */ - cst->notpositioned = 1; + cst->notpositioned = true; /* __wt_cursor_init is last so we don't have to clean up on error. */ WT_ERR(__wt_cursor_init(cursor, uri, NULL, cfg, cursorp)); diff --git a/src/third_party/wiredtiger/src/evict/evict_file.c b/src/third_party/wiredtiger/src/evict/evict_file.c index e17dfd835ff..448de57d88e 100644 --- a/src/third_party/wiredtiger/src/evict/evict_file.c +++ b/src/third_party/wiredtiger/src/evict/evict_file.c @@ -90,7 +90,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop) WT_ASSERT(session, F_ISSET(session->dhandle, WT_DHANDLE_DEAD) || - __wt_page_can_evict(session, page, false, NULL)); + __wt_page_can_evict(session, ref, false, NULL)); __wt_evict_page_clean_update(session, ref, 1); break; WT_ILLEGAL_VALUE_ERR(session); diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c index 87f7da23c94..3c00ee30896 100644 --- a/src/third_party/wiredtiger/src/evict/evict_lru.c +++ b/src/third_party/wiredtiger/src/evict/evict_lru.c @@ -313,7 +313,7 @@ __wt_evict_create(WT_SESSION_IMPL *session) */ WT_RET(__wt_thread_create( session, &conn->evict_tid, __evict_server, session)); - conn->evict_tid_set = 1; + conn->evict_tid_set = true; return (0); } @@ -349,7 +349,7 @@ __wt_evict_destroy(WT_SESSION_IMPL *session) if (conn->evict_tid_set) { WT_TRET(__wt_evict_server_wake(session)); WT_TRET(__wt_thread_join(session, conn->evict_tid)); - conn->evict_tid_set = 0; + conn->evict_tid_set = false; } WT_TRET(__wt_verbose( @@ -1221,7 +1221,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) page->read_gen = __wt_cache_read_gen_new(session); fast: /* If the page can't be evicted, give up. */ - if (!__wt_page_can_evict(session, page, true, NULL)) + if (!__wt_page_can_evict(session, ref, true, NULL)) continue; /* diff --git a/src/third_party/wiredtiger/src/evict/evict_page.c b/src/third_party/wiredtiger/src/evict/evict_page.c index bbe929b4a43..fb42b928f28 100644 --- a/src/third_party/wiredtiger/src/evict/evict_page.c +++ b/src/third_party/wiredtiger/src/evict/evict_page.c @@ -344,7 +344,7 @@ __evict_review( if (__wt_page_is_modified(page)) __wt_txn_update_oldest(session, true); - if (!__wt_page_can_evict(session, page, false, inmem_splitp)) + if (!__wt_page_can_evict(session, ref, false, inmem_splitp)) return (EBUSY); /* diff --git a/src/third_party/wiredtiger/src/include/api.h b/src/third_party/wiredtiger/src/include/api.h index 271425ded5b..8679b9510a8 100644 --- a/src/third_party/wiredtiger/src/include/api.h +++ b/src/third_party/wiredtiger/src/include/api.h @@ -43,7 +43,7 @@ /* An API call wrapped in a transaction if necessary. */ #define TXN_API_CALL(s, h, n, cur, bt, config, cfg) do { \ - int __autotxn = 0; \ + bool __autotxn = false; \ API_CALL(s, h, n, bt, cur, config, cfg); \ __autotxn = !F_ISSET(&(s)->txn, WT_TXN_AUTOCOMMIT | WT_TXN_RUNNING);\ if (__autotxn) \ @@ -51,7 +51,7 @@ /* An API call wrapped in a transaction if necessary. */ #define TXN_API_CALL_NOCONF(s, h, n, cur, bt) do { \ - int __autotxn = 0; \ + bool __autotxn = false; \ API_CALL_NOCONF(s, h, n, cur, bt); \ __autotxn = !F_ISSET(&(s)->txn, WT_TXN_AUTOCOMMIT | WT_TXN_RUNNING);\ if (__autotxn) \ diff --git a/src/third_party/wiredtiger/src/include/block.h b/src/third_party/wiredtiger/src/include/block.h index 41f2423206b..aa141e1df71 100644 --- a/src/third_party/wiredtiger/src/include/block.h +++ b/src/third_party/wiredtiger/src/include/block.h @@ -238,7 +238,7 @@ struct __wt_block { */ WT_SPINLOCK live_lock; /* Live checkpoint lock */ WT_BLOCK_CKPT live; /* Live checkpoint */ - int ckpt_inprogress;/* Live checkpoint in progress */ + bool ckpt_inprogress;/* Live checkpoint in progress */ /* Compaction support */ int compact_pct_tenths; /* Percent to compact */ diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index 61c0f3cbecf..0302533bb04 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -288,11 +288,9 @@ struct __wt_page_modify { uint32_t cksum; } *multi; uint32_t multi_entries; /* Multiple blocks element count */ - bool multi_row_ovfl; /* Row-store overflow key/values */ } m; #define mod_multi u1.m.multi #define mod_multi_entries u1.m.multi_entries -#define mod_multi_row_ovfl u1.m.multi_row_ovfl } u1; /* @@ -579,8 +577,9 @@ struct __wt_page { #define WT_PAGE_DISK_ALLOC 0x02 /* Disk image in allocated memory */ #define WT_PAGE_DISK_MAPPED 0x04 /* Disk image in mapped memory */ #define WT_PAGE_EVICT_LRU 0x08 /* Page is on the LRU queue */ -#define WT_PAGE_RECONCILIATION 0x10 /* Page reconciliation lock */ -#define WT_PAGE_SPLIT_INSERT 0x20 /* A leaf page was split for append */ +#define WT_PAGE_OVERFLOW_KEYS 0x10 /* Page has overflow keys */ +#define WT_PAGE_RECONCILIATION 0x20 /* Page reconciliation lock */ +#define WT_PAGE_SPLIT_INSERT 0x40 /* A leaf page was split for append */ uint8_t flags_atomic; /* Atomic flags, use F_*_ATOMIC */ /* diff --git a/src/third_party/wiredtiger/src/include/btree.h b/src/third_party/wiredtiger/src/include/btree.h index acfcef2ab47..ccdcccbaa0e 100644 --- a/src/third_party/wiredtiger/src/include/btree.h +++ b/src/third_party/wiredtiger/src/include/btree.h @@ -102,9 +102,9 @@ struct __wt_btree { * Reconciliation... */ u_int dictionary; /* Dictionary slots */ - int internal_key_truncate; /* Internal key truncate */ + bool internal_key_truncate; /* Internal key truncate */ int maximum_depth; /* Maximum tree depth */ - int prefix_compression; /* Prefix compression */ + bool prefix_compression; /* Prefix compression */ u_int prefix_compression_min; /* Prefix compression min */ #define WT_SPLIT_DEEPEN_MIN_CHILD_DEF 10000 u_int split_deepen_min_child; /* Minimum entries to deepen tree */ @@ -172,5 +172,5 @@ struct __wt_salvage_cookie { uint64_t skip; /* Initial items to skip */ uint64_t take; /* Items to take */ - int done; /* Ignore the rest */ + bool done; /* Ignore the rest */ }; diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i index 6200c5e21d0..c7466019e14 100644 --- a/src/third_party/wiredtiger/src/include/btree.i +++ b/src/third_party/wiredtiger/src/include/btree.i @@ -1035,9 +1035,10 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page) */ static inline bool __wt_page_can_evict(WT_SESSION_IMPL *session, - WT_PAGE *page, bool check_splits, bool *inmem_splitp) + WT_REF *ref, bool check_splits, bool *inmem_splitp) { WT_BTREE *btree; + WT_PAGE *page; WT_PAGE_MODIFY *mod; WT_TXN_GLOBAL *txn_global; @@ -1045,6 +1046,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, *inmem_splitp = false; btree = S2BT(session); + page = ref->page; mod = page->modify; /* Pages that have never been modified can always be evicted. */ @@ -1077,13 +1079,13 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, } /* - * We can't evict clean, multiblock row-store pages with overflow keys - * when the file is being checkpointed: the split into the parent frees - * the backing blocks for no-longer-used overflow keys, corrupting the - * checkpoint's block management. + * We can't evict clean, multiblock row-store pages where the parent's + * key for the page is an overflow item, because the split into the + * parent frees the backing blocks for any no-longer-used overflow keys, + * which will corrupt the checkpoint's block management. */ if (btree->checkpointing && - mod->rec_result == WT_PM_REC_MULTIBLOCK && mod->mod_multi_row_ovfl) + F_ISSET_ATOMIC(ref->home, WT_PAGE_OVERFLOW_KEYS)) return (false); /* @@ -1206,7 +1208,7 @@ __wt_page_release(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) LF_ISSET(WT_READ_NO_EVICT) || F_ISSET(session, WT_SESSION_NO_EVICTION) || F_ISSET(btree, WT_BTREE_NO_EVICTION) || - !__wt_page_can_evict(session, page, true, NULL)) + !__wt_page_can_evict(session, ref, true, NULL)) return (__wt_hazard_clear(session, page)); WT_RET_BUSY_OK(__wt_page_release_evict(session, ref)); diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index d8ff261cd82..2c20c2f7936 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -277,11 +277,11 @@ struct __wt_connection_impl { WT_TXN_GLOBAL txn_global; /* Global transaction state */ WT_RWLOCK *hot_backup_lock; /* Hot backup serialization */ - int hot_backup; + bool hot_backup; WT_SESSION_IMPL *ckpt_session; /* Checkpoint thread session */ wt_thread_t ckpt_tid; /* Checkpoint thread */ - int ckpt_tid_set; /* Checkpoint thread set */ + bool ckpt_tid_set; /* Checkpoint thread set */ WT_CONDVAR *ckpt_cond; /* Checkpoint wait mutex */ const char *ckpt_config; /* Checkpoint configuration */ #define WT_CKPT_LOGSIZE(conn) ((conn)->ckpt_logsize != 0) @@ -317,7 +317,7 @@ struct __wt_connection_impl { WT_SESSION_IMPL *evict_session; /* Eviction server sessions */ wt_thread_t evict_tid; /* Eviction server thread ID */ - int evict_tid_set; /* Eviction server thread ID set */ + bool evict_tid_set; /* Eviction server thread ID set */ uint32_t evict_workers_alloc;/* Allocated eviction workers */ uint32_t evict_workers_max;/* Max eviction workers */ @@ -327,7 +327,7 @@ struct __wt_connection_impl { WT_SESSION_IMPL *stat_session; /* Statistics log session */ wt_thread_t stat_tid; /* Statistics log thread */ - int stat_tid_set; /* Statistics log thread set */ + bool stat_tid_set; /* Statistics log thread set */ WT_CONDVAR *stat_cond; /* Statistics log wait mutex */ const char *stat_format; /* Statistics log timestamp format */ FILE *stat_fp; /* Statistics log file handle */ @@ -346,15 +346,15 @@ struct __wt_connection_impl { WT_CONDVAR *log_cond; /* Log server wait mutex */ WT_SESSION_IMPL *log_session; /* Log server session */ wt_thread_t log_tid; /* Log server thread */ - int log_tid_set; /* Log server thread set */ + bool log_tid_set; /* Log server thread set */ WT_CONDVAR *log_file_cond; /* Log file thread wait mutex */ WT_SESSION_IMPL *log_file_session;/* Log file thread session */ wt_thread_t log_file_tid; /* Log file thread thread */ - int log_file_tid_set;/* Log file thread set */ + bool log_file_tid_set;/* Log file thread set */ WT_CONDVAR *log_wrlsn_cond;/* Log write lsn thread wait mutex */ WT_SESSION_IMPL *log_wrlsn_session;/* Log write lsn thread session */ wt_thread_t log_wrlsn_tid; /* Log write lsn thread thread */ - int log_wrlsn_tid_set;/* Log write lsn thread set */ + bool log_wrlsn_tid_set;/* Log write lsn thread set */ WT_LOG *log; /* Logging structure */ WT_COMPRESSOR *log_compressor;/* Logging compressor */ wt_off_t log_file_max; /* Log file max size */ @@ -411,7 +411,7 @@ struct __wt_connection_impl { wt_off_t log_extend_len; /* file_extend log length */ uint32_t direct_io; /* O_DIRECT file type flags */ - int mmap; /* mmap configuration */ + bool mmap; /* mmap configuration */ uint32_t verbose; uint32_t flags; diff --git a/src/third_party/wiredtiger/src/include/cursor.h b/src/third_party/wiredtiger/src/include/cursor.h index 4c132cbbf9c..1cbe76216b1 100644 --- a/src/third_party/wiredtiger/src/include/cursor.h +++ b/src/third_party/wiredtiger/src/include/cursor.h @@ -228,7 +228,7 @@ struct __wt_cursor_bulk { uint32_t nrecs; /* Max records per chunk */ /* Special bitmap bulk load for fixed-length column stores. */ - int bitmap; + bool bitmap; void *reconcile; /* Reconciliation information */ }; @@ -301,8 +301,8 @@ struct __wt_cursor_metadata { struct __wt_cursor_stat { WT_CURSOR iface; - int notinitialized; /* Cursor not initialized */ - int notpositioned; /* Cursor not positioned */ + bool notinitialized; /* Cursor not initialized */ + bool notpositioned; /* Cursor not positioned */ int64_t *stats; /* Statistics */ int stats_base; /* Base statistics value */ diff --git a/src/third_party/wiredtiger/src/include/intpack.i b/src/third_party/wiredtiger/src/include/intpack.i index 0830704fb6d..a13ad05451d 100644 --- a/src/third_party/wiredtiger/src/include/intpack.i +++ b/src/third_party/wiredtiger/src/include/intpack.i @@ -38,8 +38,8 @@ #define POS_2BYTE_MARKER (uint8_t)0xc0 #define POS_MULTI_MARKER (uint8_t)0xe0 -#define NEG_1BYTE_MIN ((-1) << 6) -#define NEG_2BYTE_MIN (((-1) << 13) + NEG_1BYTE_MIN) +#define NEG_1BYTE_MIN (-(1 << 6)) +#define NEG_2BYTE_MIN (-(1 << 13) + NEG_1BYTE_MIN) #define POS_1BYTE_MAX ((1 << 6) - 1) #define POS_2BYTE_MAX ((1 << 13) + POS_1BYTE_MAX) diff --git a/src/third_party/wiredtiger/src/include/os.h b/src/third_party/wiredtiger/src/include/os.h index a8bf59f25d3..4ba588111b8 100644 --- a/src/third_party/wiredtiger/src/include/os.h +++ b/src/third_party/wiredtiger/src/include/os.h @@ -101,5 +101,5 @@ struct __wt_fh { WT_FALLOCATE_POSIX, WT_FALLOCATE_STD, WT_FALLOCATE_SYS } fallocate_available; - int fallocate_requires_locking; + bool fallocate_requires_locking; }; diff --git a/src/third_party/wiredtiger/src/include/schema.h b/src/third_party/wiredtiger/src/include/schema.h index b226d1f2b50..023fd398f1c 100644 --- a/src/third_party/wiredtiger/src/include/schema.h +++ b/src/third_party/wiredtiger/src/include/schema.h @@ -141,37 +141,37 @@ struct __wt_table { * Drop the handle, table and/or schema locks, perform an operation, * re-acquire the lock(s). */ -#define WT_WITHOUT_LOCKS(session, op) do { \ - WT_CONNECTION_IMPL *__conn = S2C(session); \ - int __handle_locked = \ - F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST);\ - int __table_locked = \ - F_ISSET(session, WT_SESSION_LOCKED_TABLE); \ - int __schema_locked = \ - F_ISSET(session, WT_SESSION_LOCKED_SCHEMA); \ - if (__handle_locked) { \ - F_CLR(session, WT_SESSION_LOCKED_HANDLE_LIST); \ - __wt_spin_unlock(session, &__conn->dhandle_lock);\ - } \ - if (__table_locked) { \ - F_CLR(session, WT_SESSION_LOCKED_TABLE); \ - __wt_spin_unlock(session, &__conn->table_lock);\ - } \ - if (__schema_locked) { \ - F_CLR(session, WT_SESSION_LOCKED_SCHEMA); \ - __wt_spin_unlock(session, &__conn->schema_lock);\ - } \ - op; \ - if (__schema_locked) { \ - __wt_spin_lock(session, &__conn->schema_lock); \ - F_SET(session, WT_SESSION_LOCKED_SCHEMA); \ - } \ - if (__table_locked) { \ - __wt_spin_lock(session, &__conn->table_lock); \ - F_SET(session, WT_SESSION_LOCKED_TABLE); \ - } \ - if (__handle_locked) { \ - __wt_spin_lock(session, &__conn->dhandle_lock); \ - F_SET(session, WT_SESSION_LOCKED_HANDLE_LIST); \ - } \ +#define WT_WITHOUT_LOCKS(session, op) do { \ + WT_CONNECTION_IMPL *__conn = S2C(session); \ + bool __handle_locked = \ + F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST); \ + bool __table_locked = \ + F_ISSET(session, WT_SESSION_LOCKED_TABLE); \ + bool __schema_locked = \ + F_ISSET(session, WT_SESSION_LOCKED_SCHEMA); \ + if (__handle_locked) { \ + F_CLR(session, WT_SESSION_LOCKED_HANDLE_LIST); \ + __wt_spin_unlock(session, &__conn->dhandle_lock); \ + } \ + if (__table_locked) { \ + F_CLR(session, WT_SESSION_LOCKED_TABLE); \ + __wt_spin_unlock(session, &__conn->table_lock); \ + } \ + if (__schema_locked) { \ + F_CLR(session, WT_SESSION_LOCKED_SCHEMA); \ + __wt_spin_unlock(session, &__conn->schema_lock); \ + } \ + op; \ + if (__schema_locked) { \ + __wt_spin_lock(session, &__conn->schema_lock); \ + F_SET(session, WT_SESSION_LOCKED_SCHEMA); \ + } \ + if (__table_locked) { \ + __wt_spin_lock(session, &__conn->table_lock); \ + F_SET(session, WT_SESSION_LOCKED_TABLE); \ + } \ + if (__handle_locked) { \ + __wt_spin_lock(session, &__conn->dhandle_lock); \ + F_SET(session, WT_SESSION_LOCKED_HANDLE_LIST); \ + } \ } while (0) diff --git a/src/third_party/wiredtiger/src/include/session.h b/src/third_party/wiredtiger/src/include/session.h index a691794fd46..5c3bcfb8ed0 100644 --- a/src/third_party/wiredtiger/src/include/session.h +++ b/src/third_party/wiredtiger/src/include/session.h @@ -134,7 +134,7 @@ struct WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT) __wt_session_impl { void *reconcile; /* Reconciliation support */ int (*reconcile_cleanup)(WT_SESSION_IMPL *); - int compaction; /* Compaction did some work */ + bool compaction; /* Compaction did some work */ uint32_t flags; diff --git a/src/third_party/wiredtiger/src/include/txn.h b/src/third_party/wiredtiger/src/include/txn.h index 4a325c70a95..7a07d16045d 100644 --- a/src/third_party/wiredtiger/src/include/txn.h +++ b/src/third_party/wiredtiger/src/include/txn.h @@ -153,7 +153,7 @@ struct __wt_txn { /* Checkpoint status. */ WT_LSN ckpt_lsn; - int full_ckpt; + bool full_ckpt; uint32_t ckpt_nsnapshot; WT_ITEM *ckpt_snapshot; diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c index 29b19443ae4..ca0b81c4cf6 100644 --- a/src/third_party/wiredtiger/src/log/log.c +++ b/src/third_party/wiredtiger/src/log/log.c @@ -738,9 +738,8 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) /* * If we get any error other than WT_NOTFOUND, return it. */ - if (ret != 0 && ret != WT_NOTFOUND) - return (ret); - ret = 0; + WT_RET_NOTFOUND_OK(ret); + if (create_log) { WT_STAT_FAST_CONN_INCR(session, log_prealloc_missed); if (conn->log_cond != NULL) @@ -1206,11 +1205,11 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) WT_LSN sync_lsn; int64_t release_buffered, release_bytes; int yield_count; - bool locked, need_relock; + bool locked; conn = S2C(session); log = conn->log; - locked = need_relock = false; + locked = false; yield_count = 0; if (freep != NULL) *freep = 1; @@ -1257,7 +1256,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) * and more walking of the slot pool for a very small number * of slots to process. Don't signal here. */ - goto done; + return (0); } /* @@ -1271,19 +1270,15 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) * unlock in case an earlier thread is trying to switch its * slot and complete its operation. */ - if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) { + if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) __wt_spin_unlock(session, &log->log_slot_lock); - need_relock = true; - } if (++yield_count < 1000) __wt_yield(); else - WT_ERR(__wt_cond_wait( - session, log->log_write_cond, 200)); - if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) { + ret = __wt_cond_wait(session, log->log_write_cond, 200); + if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) __wt_spin_lock(session, &log->log_slot_lock); - need_relock = false; - } + WT_ERR(ret); } log->write_start_lsn = slot->slot_start_lsn; @@ -1363,11 +1358,8 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) } err: if (locked) __wt_spin_unlock(session, &log->log_sync_lock); - if (need_relock) - __wt_spin_lock(session, &log->log_slot_lock); if (ret != 0 && slot->slot_error == 0) slot->slot_error = ret; -done: return (ret); } diff --git a/src/third_party/wiredtiger/src/log/log_slot.c b/src/third_party/wiredtiger/src/log/log_slot.c index fcfa1d242c6..7c541eb7bec 100644 --- a/src/third_party/wiredtiger/src/log/log_slot.c +++ b/src/third_party/wiredtiger/src/log/log_slot.c @@ -26,6 +26,9 @@ __wt_log_slot_activate(WT_SESSION_IMPL *session, WT_LOGSLOT *slot) * !!! slot_release_lsn must be set outside this function because * this function may be called after a log file switch and the * slot_release_lsn must refer to the end of the previous log. + * !!! We cannot initialize flags here because it may already be + * set for closing the file handle on a log file switch. The flags + * are reset when the slot is freed. See log_slot_free. */ slot->slot_start_lsn = slot->slot_end_lsn = log->alloc_lsn; slot->slot_start_offset = log->alloc_lsn.offset; @@ -33,7 +36,6 @@ __wt_log_slot_activate(WT_SESSION_IMPL *session, WT_LOGSLOT *slot) slot->slot_fh = log->log_fh; slot->slot_error = 0; slot->slot_unbuffered = 0; - slot->flags = WT_SLOT_INIT_FLAGS; } /* @@ -484,6 +486,14 @@ __wt_log_slot_release(WT_SESSION_IMPL *session, WT_MYSLOT *myslot, int64_t size) void __wt_log_slot_free(WT_SESSION_IMPL *session, WT_LOGSLOT *slot) { + /* + * Make sure flags don't get retained between uses. + * We have to reset them here and not in log_slot_activate because + * some flags (such as closing the file handle) may be set before + * we initialize the rest of the slot. + */ WT_UNUSED(session); + slot->flags = WT_SLOT_INIT_FLAGS; + slot->slot_error = 0; slot->slot_state = WT_LOG_SLOT_FREE; } 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 a0cd2e5dba2..7056c907f8e 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -561,7 +561,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) * prevents us from removing a file that hot backup already * knows about. */ - if (S2C(session)->hot_backup != 0) + if (S2C(session)->hot_backup) break; /* diff --git a/src/third_party/wiredtiger/src/meta/meta_track.c b/src/third_party/wiredtiger/src/meta/meta_track.c index e82ae902f92..b223c2fb8fc 100644 --- a/src/third_party/wiredtiger/src/meta/meta_track.c +++ b/src/third_party/wiredtiger/src/meta/meta_track.c @@ -130,7 +130,6 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk) WT_BM *bm; WT_BTREE *btree; WT_DECL_RET; - int tret; switch (trk->op) { case WT_ST_EMPTY: /* Unused slot */ @@ -139,19 +138,16 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk) btree = trk->dhandle->handle; bm = btree->bm; WT_WITH_DHANDLE(session, trk->dhandle, - WT_TRET(bm->checkpoint_resolve(bm, session))); + ret = bm->checkpoint_resolve(bm, session)); break; case WT_ST_DROP_COMMIT: - if ((tret = __wt_remove_if_exists(session, trk->a)) != 0) { - __wt_err(session, tret, - "metadata remove dropped file %s", - trk->a); - WT_TRET(tret); - } + if ((ret = __wt_remove_if_exists(session, trk->a)) != 0) + __wt_err(session, ret, + "metadata remove dropped file %s", trk->a); break; case WT_ST_LOCK: WT_WITH_DHANDLE(session, trk->dhandle, - WT_TRET(__wt_session_release_btree(session))); + ret = __wt_session_release_btree(session)); break; case WT_ST_FILEOP: case WT_ST_REMOVE: @@ -172,7 +168,6 @@ static int __meta_track_unroll(WT_SESSION_IMPL *session, WT_META_TRACK *trk) { WT_DECL_RET; - int tret; switch (trk->op) { case WT_ST_EMPTY: /* Unused slot */ @@ -185,7 +180,7 @@ __meta_track_unroll(WT_SESSION_IMPL *session, WT_META_TRACK *trk) if (trk->created) F_SET(trk->dhandle, WT_DHANDLE_DISCARD); WT_WITH_DHANDLE(session, trk->dhandle, - WT_TRET(__wt_session_release_btree(session))); + ret = __wt_session_release_btree(session)); break; case WT_ST_FILEOP: /* File operation */ /* @@ -194,22 +189,16 @@ __meta_track_unroll(WT_SESSION_IMPL *session, WT_META_TRACK *trk) * For removes, b is NULL. */ if (trk->a != NULL && trk->b != NULL && - (tret = __wt_rename(session, - trk->b + strlen("file:"), - trk->a + strlen("file:"))) != 0) { - __wt_err(session, tret, - "metadata unroll rename %s to %s", - trk->b, trk->a); - WT_TRET(tret); - } else if (trk->a == NULL) { - if ((tret = __wt_remove(session, - trk->b + strlen("file:"))) != 0) { - __wt_err(session, tret, - "metadata unroll create %s", - trk->b); - WT_TRET(tret); - } - } + (ret = __wt_rename(session, + trk->b + strlen("file:"), trk->a + strlen("file:"))) != 0) + __wt_err(session, ret, + "metadata unroll rename %s to %s", trk->b, trk->a); + + if (trk->a == NULL && + (ret = __wt_remove(session, trk->b + strlen("file:"))) != 0) + __wt_err(session, ret, + "metadata unroll create %s", trk->b); + /* * We can't undo removes yet: that would imply * some kind of temporary rename and remove in @@ -217,21 +206,14 @@ __meta_track_unroll(WT_SESSION_IMPL *session, WT_META_TRACK *trk) */ break; case WT_ST_REMOVE: /* Remove trk.a */ - if ((tret = __wt_metadata_remove(session, trk->a)) != 0) { - __wt_err(session, tret, - "metadata unroll remove: %s", - trk->a); - WT_TRET(tret); - } + if ((ret = __wt_metadata_remove(session, trk->a)) != 0) + __wt_err(session, ret, + "metadata unroll remove: %s", trk->a); break; case WT_ST_SET: /* Set trk.a to trk.b */ - if ((tret = __wt_metadata_update( - session, trk->a, trk->b)) != 0) { - __wt_err(session, tret, - "metadata unroll update %s to %s", - trk->a, trk->b); - WT_TRET(tret); - } + if ((ret = __wt_metadata_update(session, trk->a, trk->b)) != 0) + __wt_err(session, ret, + "metadata unroll update %s to %s", trk->a, trk->b); break; WT_ILLEGAL_VALUE(session); } diff --git a/src/third_party/wiredtiger/src/os_posix/os_fallocate.c b/src/third_party/wiredtiger/src/os_posix/os_fallocate.c index 142374702a1..20a9e8236ac 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_fallocate.c +++ b/src/third_party/wiredtiger/src/os_posix/os_fallocate.c @@ -22,7 +22,7 @@ __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh) WT_UNUSED(session); fh->fallocate_available = WT_FALLOCATE_NOT_AVAILABLE; - fh->fallocate_requires_locking = 0; + fh->fallocate_requires_locking = false; /* * Check for the availability of some form of fallocate; in all cases, @@ -31,11 +31,11 @@ __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh) */ #if defined(HAVE_FALLOCATE) || defined(HAVE_POSIX_FALLOCATE) fh->fallocate_available = WT_FALLOCATE_AVAILABLE; - fh->fallocate_requires_locking = 1; + fh->fallocate_requires_locking = true; #endif #if defined(__linux__) && defined(SYS_fallocate) fh->fallocate_available = WT_FALLOCATE_AVAILABLE; - fh->fallocate_requires_locking = 1; + fh->fallocate_requires_locking = true; #endif } @@ -155,18 +155,18 @@ __wt_fallocate( */ if ((ret = __wt_std_fallocate(fh, offset, len)) == 0) { fh->fallocate_available = WT_FALLOCATE_STD; - fh->fallocate_requires_locking = 0; + fh->fallocate_requires_locking = false; return (0); } if ((ret = __wt_sys_fallocate(fh, offset, len)) == 0) { fh->fallocate_available = WT_FALLOCATE_SYS; - fh->fallocate_requires_locking = 0; + fh->fallocate_requires_locking = false; return (0); } if ((ret = __wt_posix_fallocate(fh, offset, len)) == 0) { fh->fallocate_available = WT_FALLOCATE_POSIX; #if !defined(__linux__) - fh->fallocate_requires_locking = 0; + fh->fallocate_requires_locking = false; #endif return (0); } diff --git a/src/third_party/wiredtiger/src/os_win/os_fallocate.c b/src/third_party/wiredtiger/src/os_win/os_fallocate.c index ee1335af12e..030c2e4c6c7 100644 --- a/src/third_party/wiredtiger/src/os_win/os_fallocate.c +++ b/src/third_party/wiredtiger/src/os_win/os_fallocate.c @@ -24,7 +24,7 @@ __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh) * support the call. */ fh->fallocate_available = WT_FALLOCATE_NOT_AVAILABLE; - fh->fallocate_requires_locking = 0; + fh->fallocate_requires_locking = false; } /* diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index 3ad90aeb58c..82264f7c58f 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -715,7 +715,7 @@ __rec_raw_compression_config( return (false); /* Raw compression cannot support prefix compression. */ - if (btree->prefix_compression != 0) + if (btree->prefix_compression) return (false); /* @@ -4091,7 +4091,7 @@ __rec_col_var_helper(WT_SESSION_IMPL *session, WT_RECONCILE *r, salvage->take = 0; } if (salvage->take == 0) - salvage->done = 1; + salvage->done = true; } } @@ -4564,6 +4564,10 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) vpack = &_vpack; WT_CLEAR(*vpack); /* -Wuninitialized */ + ikey = NULL; /* -Wuninitialized */ + cell = NULL; + key_onpage_ovfl = false; + WT_RET(__rec_split_init(session, r, page, 0ULL, btree->maxintlpage)); /* @@ -4593,17 +4597,20 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * things up. * * Note the cell reference and unpacked key cell are available - * only in the case of an instantiated, off-page key. + * only in the case of an instantiated, off-page key, we don't + * bother setting them if that's not possible. */ - ikey = __wt_ref_key_instantiated(ref); - if (ikey == NULL || ikey->cell_offset == 0) { + if (F_ISSET_ATOMIC(page, WT_PAGE_OVERFLOW_KEYS)) { cell = NULL; key_onpage_ovfl = false; - } else { - cell = WT_PAGE_REF_OFFSET(page, ikey->cell_offset); - __wt_cell_unpack(cell, kpack); - key_onpage_ovfl = - kpack->ovfl && kpack->raw != WT_CELL_KEY_OVFL_RM; + ikey = __wt_ref_key_instantiated(ref); + if (ikey != NULL && ikey->cell_offset != 0) { + cell = + WT_PAGE_REF_OFFSET(page, ikey->cell_offset); + __wt_cell_unpack(cell, kpack); + key_onpage_ovfl = kpack->ovfl && + kpack->raw != WT_CELL_KEY_OVFL_RM; + } } WT_ERR(__rec_child_modify(session, r, ref, &hazard, &state)); @@ -5667,15 +5674,6 @@ __rec_split_row(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) } mod->mod_multi_entries = r->bnd_next; - /* - * We can't evict clean, multiblock row-store pages with overflow keys - * when the file is being checkpointed: the split into the parent frees - * the backing blocks for no-longer-used overflow keys, corrupting the - * checkpoint's block management. Column-store pages have no overflow - * keys, so they're not a problem, track overflow items for row-store. - */ - mod->mod_multi_row_ovfl = r->ovfl_items; - return (0); } diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c index 98509ecdceb..1bb519e80e0 100644 --- a/src/third_party/wiredtiger/src/session/session_api.c +++ b/src/third_party/wiredtiger/src/session/session_api.c @@ -1007,6 +1007,13 @@ __session_transaction_sync(WT_SESSION *wt_session, const char *config) WT_ERR(__wt_epoch(session, &now)); waited_ms = WT_TIMEDIFF(now, start) / WT_MILLION; if (forever || waited_ms < timeout_ms) + /* + * Note, we will wait an increasing amount of time + * each iteration, likely doubling. Also note that + * the function timeout value is in usecs (we are + * computing the wait time in msecs and passing that + * in, unchanged, as the usecs to wait). + */ WT_ERR(__wt_cond_wait( session, log->log_sync_cond, waited_ms)); else diff --git a/src/third_party/wiredtiger/src/session/session_compact.c b/src/third_party/wiredtiger/src/session/session_compact.c index cd2c9ddb35d..bbd4bbc536c 100644 --- a/src/third_party/wiredtiger/src/session/session_compact.c +++ b/src/third_party/wiredtiger/src/session/session_compact.c @@ -184,7 +184,7 @@ __compact_file(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) for (i = 0; i < 100; ++i) { WT_ERR(wt_session->checkpoint(wt_session, t->data)); - session->compaction = 0; + session->compaction = false; WT_WITH_SCHEMA_LOCK(session, ret = __wt_schema_worker( session, uri, __wt_compact, NULL, cfg, 0)); diff --git a/src/third_party/wiredtiger/src/support/huffman.c b/src/third_party/wiredtiger/src/support/huffman.c index 966257bb080..4bda365cb10 100644 --- a/src/third_party/wiredtiger/src/support/huffman.c +++ b/src/third_party/wiredtiger/src/support/huffman.c @@ -790,6 +790,16 @@ __wt_huffman_decode(WT_SESSION_IMPL *session, void *huffman_arg, symbol = huffman->code2symbol[pattern & mask]; len = huffman->codes[symbol].length; valid -= len; + + /* + * from_len_bits is the total number of input bits, reduced by + * the number of bits we consume from input at each step. For + * all but the last step from_len_bits > len, then at the last + * step from_len_bits == len (in other words, from_len_bits - + * len = 0 input bits remaining). Generally, we cannot detect + * corruption during huffman decompression, this is one place + * where that's not true. + */ if (from_len_bits < len) /* corrupted */ WT_ERR(EINVAL); from_len_bits -= len; diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c index 05efd00aff8..c5fa52dea6a 100644 --- a/src/third_party/wiredtiger/src/txn/txn_log.c +++ b/src/third_party/wiredtiger/src/txn/txn_log.c @@ -307,7 +307,7 @@ __wt_txn_checkpoint_log( switch (flags) { case WT_TXN_LOG_CKPT_PREPARE: - txn->full_ckpt = 1; + txn->full_ckpt = true; WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, true)); /* * We need to make sure that the log records in the checkpoint @@ -374,7 +374,7 @@ __wt_txn_checkpoint_log( WT_INIT_LSN(ckpt_lsn); txn->ckpt_nsnapshot = 0; __wt_scr_free(session, &txn->ckpt_snapshot); - txn->full_ckpt = 0; + txn->full_ckpt = false; break; WT_ILLEGAL_VALUE_ERR(session); } -- cgit v1.2.1