summaryrefslogtreecommitdiff
path: root/src/btree/bt_discard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree/bt_discard.c')
-rw-r--r--src/btree/bt_discard.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/btree/bt_discard.c b/src/btree/bt_discard.c
index 162bc07a1c2..7858d2cb14e 100644
--- a/src/btree/bt_discard.c
+++ b/src/btree/bt_discard.c
@@ -27,9 +27,35 @@ __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref)
/*
* A version of the page-out function that allows us to make additional
* diagnostic checks.
+ *
+ * The WT_REF cannot be the eviction thread's location.
*/
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.
+ */
+ for (hp = NULL, i = 0; i < 100; i++) {
+ if ((hp = __wt_page_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_page_out(session, &ref->page);
}
@@ -63,30 +89,6 @@ __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep)
WT_ASSERT(session, !F_ISSET_ATOMIC(page, WT_PAGE_EVICT_LRU));
WT_ASSERT(session, !__wt_rwlock_islocked(session, &page->page_lock));
-#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.
- */
- for (hp = NULL, i = 0; i < 100; i++) {
- if ((hp = __wt_page_hazard_check(session, page)) == NULL)
- break;
- __wt_sleep(0, 10000);
- }
- if (hp != NULL)
- __wt_errx(session,
- "discarded page has hazard pointer: (%p: %s, line %d)",
- (void *)hp->page, hp->file, hp->line);
- WT_ASSERT(session, hp == NULL);
- }
-#endif
-
/*
* If a root page split, there may be one or more pages linked from the
* page; walk the list, discarding pages.