diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2017-03-02 21:17:25 -0500 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2017-03-03 13:17:25 +1100 |
commit | 62f0543765deaf2f11b3c2e78d82940e500f004b (patch) | |
tree | d708fde5040bdc25c68fbf286dd52395bbe79def /src/include | |
parent | f70d3773671a5a9319900b4aef57bdc1a67afdc0 (diff) | |
download | mongo-62f0543765deaf2f11b3c2e78d82940e500f004b.tar.gz |
WT-3203 bulk-load state changes can race (#3318)
* The bulk-load state change (where multiple threads of control turn off the possibility of bulk-load in a tree), has always been able to race, but it's potentially dangerous now that turning off bulk-load involves calling `__wt_evict_file_exclusive_off()`. In the current tree, there's a diagnostic-only test that might fail because of this race.
* The WT_BTREE_NO_EVICTION flag is no longer set other than through the __wt_evict_file_exclusive_on/off functions; remove that flag and use the WT_BTREE.evict_disabled counter by itself.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/btree.h | 20 | ||||
-rw-r--r-- | src/include/btree.i | 7 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/include/btree.h b/src/include/btree.h index 69ab2070eb9..fc7cd352883 100644 --- a/src/include/btree.h +++ b/src/include/btree.h @@ -120,7 +120,8 @@ struct __wt_btree { WT_REF root; /* Root page reference */ bool modified; /* If the tree ever modified */ - bool bulk_load_ok; /* Bulk-load is a possibility */ + uint8_t bulk_load_ok; /* Bulk-load is a possibility + (want a bool but needs atomic cas) */ WT_BM *bm; /* Block manager reference */ u_int block_header; /* WT_PAGE_HEADER_BYTE_SIZE */ @@ -139,7 +140,7 @@ struct __wt_btree { u_int evict_walk_period; /* Skip this many LRU walks */ u_int evict_walk_saved; /* Saved walk skips for checkpoints */ u_int evict_walk_skips; /* Number of walks skipped */ - u_int evict_disabled; /* Eviction disabled count */ + int evict_disabled; /* Eviction disabled count */ volatile uint32_t evict_busy; /* Count of threads in eviction */ int evict_start_type; /* Start position for eviction walk (see WT_EVICT_WALK_START). */ @@ -162,14 +163,13 @@ struct __wt_btree { #define WT_BTREE_LOOKASIDE 0x001000 /* Look-aside table */ #define WT_BTREE_LSM_PRIMARY 0x002000 /* Handle is current LSM primary */ #define WT_BTREE_NO_CHECKPOINT 0x004000 /* Disable checkpoints */ -#define WT_BTREE_NO_EVICTION 0x008000 /* Disable eviction */ -#define WT_BTREE_NO_LOGGING 0x010000 /* Disable logging */ -#define WT_BTREE_NO_RECONCILE 0x020000 /* Allow splits, even with no evict */ -#define WT_BTREE_REBALANCE 0x040000 /* Handle is for rebalance */ -#define WT_BTREE_SALVAGE 0x080000 /* Handle is for salvage */ -#define WT_BTREE_SKIP_CKPT 0x100000 /* Handle skipped checkpoint */ -#define WT_BTREE_UPGRADE 0x200000 /* Handle is for upgrade */ -#define WT_BTREE_VERIFY 0x400000 /* Handle is for verify */ +#define WT_BTREE_NO_LOGGING 0x008000 /* Disable logging */ +#define WT_BTREE_NO_RECONCILE 0x010000 /* Allow splits, even with no evict */ +#define WT_BTREE_REBALANCE 0x020000 /* Handle is for rebalance */ +#define WT_BTREE_SALVAGE 0x040000 /* Handle is for salvage */ +#define WT_BTREE_SKIP_CKPT 0x080000 /* Handle skipped checkpoint */ +#define WT_BTREE_UPGRADE 0x100000 /* Handle is for upgrade */ +#define WT_BTREE_VERIFY 0x200000 /* Handle is for verify */ uint32_t flags; }; diff --git a/src/include/btree.i b/src/include/btree.i index 6dda2428122..cec6f67e9bd 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -1401,7 +1401,7 @@ __wt_page_release(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) if (page->read_gen != WT_READGEN_OLDEST || LF_ISSET(WT_READ_NO_EVICT) || F_ISSET(session, WT_SESSION_NO_EVICTION) || - F_ISSET(btree, WT_BTREE_NO_EVICTION) || + btree->evict_disabled > 0 || !__wt_page_can_evict(session, ref, NULL)) return (__wt_hazard_clear(session, ref)); @@ -1521,7 +1521,7 @@ __wt_btree_lsm_over_size(WT_SESSION_IMPL *session, uint64_t maxsize) return (false); /* A tree that can be evicted always requires a switch. */ - if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) + if (btree->evict_disabled == 0) return (true); /* Check for a tree with a single leaf page. */ @@ -1569,8 +1569,7 @@ __wt_btree_lsm_switch_primary(WT_SESSION_IMPL *session, bool on) } if (!on && F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) { pindex = WT_INTL_INDEX_GET_SAFE(root); - if (!F_ISSET(btree, WT_BTREE_NO_EVICTION) || - pindex->entries != 1) + if (btree->evict_disabled == 0 || pindex->entries != 1) return (0); first = pindex->index[0]; |