From f8db6cf5707ee44b7906f00add610b705d696dc6 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Wed, 19 Apr 2017 00:34:45 -0400 Subject: WT-3292 review/cleanup full-barrier calls in WiredTiger (#3395) * Rework logging's log_close_fh and log_close_lsn barrier code. There are two fields, the close handle and the close LSN, and they both have to be set. The __log_file_server() code was checking the close handle and then spinning until the close LSN was set, but a simpler solution is to publish the close LSN write before setting the close handle. To be clear, the previous code was correct, it was the comment that was wrong. * Remove barriers from around read/write of WT_TXN_GLOBAL.checkpoint_running. The read-barrier in __compact_checkpoint() isn't needed because the check is on memory declared volatile. The full-barrier in __txn_checkpoint_wrapper isn't needed because there's no ordering constraint. * Don't flush the reset of the WT_REF.state field, we've never seen any performance reason that a barrier is needed. * Fix a comment: technically, the las-was-written flag has to be flushed before any relevant read happens, document it that way. * Instead of explicitly flushing the clear of the WT_CONN_SERVER_LSM flag, change __wt_sleep() to imply a barrier, there are loops which don't have no other barriers, like __lsm_manager_run_server(). --- src/lsm/lsm_manager.c | 6 +----- src/lsm/lsm_tree.c | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/lsm') diff --git a/src/lsm/lsm_manager.c b/src/lsm/lsm_manager.c index 88b3e1980be..f391c553d2a 100644 --- a/src/lsm/lsm_manager.c +++ b/src/lsm/lsm_manager.c @@ -284,12 +284,8 @@ __wt_lsm_manager_destroy(WT_SESSION_IMPL *session) manager = &conn->lsm_manager; removed = 0; - /* - * Clear the LSM server flag and flush to ensure running threads see - * the state change. - */ + /* Clear the LSM server flag. */ F_CLR(conn, WT_CONN_SERVER_LSM); - WT_FULL_BARRIER(); WT_ASSERT(session, !F_ISSET(conn, WT_CONN_READONLY) || manager->lsm_workers == 0); diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c index fb8eb9d38a7..fe36237969f 100644 --- a/src/lsm/lsm_tree.c +++ b/src/lsm/lsm_tree.c @@ -768,13 +768,13 @@ __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_ERR(__wt_lsm_meta_write(session, lsm_tree, NULL)); lsm_tree->need_switch = false; - ++lsm_tree->dsk_gen; - lsm_tree->modified = true; + /* * Ensure the updated disk generation is visible to all other threads * before updating the transaction ID. */ + ++lsm_tree->dsk_gen; WT_FULL_BARRIER(); /* -- cgit v1.2.1