diff options
author | Ramon Fernandez <ramon@mongodb.com> | 2016-09-26 08:10:04 -0400 |
---|---|---|
committer | Ramon Fernandez <ramon@mongodb.com> | 2016-09-26 08:10:04 -0400 |
commit | 79d9b3ab5ce20f51c272b4411202710a082d0317 (patch) | |
tree | 02896bc295ffcd4a0201bda0663160bc22de2c2a /src/third_party/wiredtiger/src/btree/bt_compact.c | |
parent | 7026ff8dbc62b9649e8be1793d3273d9cc162174 (diff) | |
download | mongo-65130e6a6cc4193431d089871f57416fbb47ec00.tar.gz |
Import wiredtiger: 9cf2f89d6d95e1de797f05ab1fef28695f8bae7b from branch mongodb-3.2r3.2.10-rc2r3.2.10
ref: bb18c43915..9cf2f89d6d
for: 3.2.10
WT-2864 Reconfiguring the checkpoint server can lead to hangs
WT-2874 Change test_compact01 to avoid eviction
WT-2918 The dist scripts create C files s_whitespace complains about
WT-2919 Don't mask error returns from style checking scripts
WT-2921 Reduce the WT_SESSION hazard_size when possible
WT-2923 heap-use-after-free on address in compaction
WT-2924 Ensure we are doing eviction when threads are waiting for it
WT-2925 WT_THREAD_PANIC_FAIL is a WT_THREAD structure flag
WT-2926 WT_CONNECTION.reconfigure can attempt unlock of not-locked lock
WT-2928 Eviction failing to switch queues can lead to starvation
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/bt_compact.c')
-rw-r--r-- | src/third_party/wiredtiger/src/btree/bt_compact.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_compact.c b/src/third_party/wiredtiger/src/btree/bt_compact.c index 7ba45f29b76..e005674762d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_compact.c +++ b/src/third_party/wiredtiger/src/btree/bt_compact.c @@ -171,30 +171,64 @@ int __wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) { WT_BM *bm; + WT_DECL_RET; size_t addr_size; u_int type; const uint8_t *addr; - *skipp = false; /* Default to reading. */ - type = 0; /* Keep compiler quiet. */ + /* + * Skip deleted pages, rewriting them doesn't seem useful; in a better + * world we'd write the parent to delete the page. + */ + if (ref->state == WT_REF_DELETED) { + *skipp = true; + return (0); + } - bm = S2BT(session)->bm; + *skipp = false; /* Default to reading */ /* - * We aren't holding a hazard pointer, so we can't look at the page - * itself, all we can look at is the WT_REF information. If there's no - * address, the page isn't on disk, but we have to read internal pages - * to walk the tree regardless; throw up our hands and read it. + * If the page is in-memory, we want to look at it (it may have been + * modified and written, and the current location is the interesting + * one in terms of compaction, not the original location). + * + * This test could be combined with the next one, but this is a cheap + * test and the next one is expensive. */ - __wt_ref_info(ref, &addr, &addr_size, &type); - if (addr == NULL) + if (ref->state != WT_REF_DISK) + return (0); + + /* + * There's nothing to prevent the WT_REF state from changing underfoot, + * which can change its address. For example, the WT_REF address might + * reference an on-page cell, and page eviction can free that memory. + * Lock the WT_REF so we can look at its address. + */ + if (!__wt_atomic_casv32(&ref->state, WT_REF_DISK, WT_REF_LOCKED)) return (0); /* + * The page is on disk, so there had better be an address; assert that + * fact, test at run-time to avoid the core dump. + * * Internal pages must be read to walk the tree; ask the block-manager * if it's useful to rewrite leaf pages, don't do the I/O if a rewrite * won't help. */ - return (type == WT_CELL_ADDR_INT ? 0 : - bm->compact_page_skip(bm, session, addr, addr_size, skipp)); + __wt_ref_info(ref, &addr, &addr_size, &type); + WT_ASSERT(session, addr != NULL); + if (addr != NULL && type != WT_CELL_ADDR_INT) { + bm = S2BT(session)->bm; + ret = bm->compact_page_skip( + bm, session, addr, addr_size, skipp); + } + + /* + * Reset the WT_REF state and push the change. The full-barrier isn't + * necessary, but it's better to keep pages in circulation than not. + */ + ref->state = WT_REF_DISK; + WT_FULL_BARRIER(); + + return (ret); } |