summaryrefslogtreecommitdiff
path: root/src/btree/bt_read.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree/bt_read.c')
-rw-r--r--src/btree/bt_read.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c
index de84a711019..3f85e58f088 100644
--- a/src/btree/bt_read.c
+++ b/src/btree/bt_read.c
@@ -8,6 +8,8 @@
#include "wt_internal.h"
+static void __btree_verbose_lookaside_read(WT_SESSION_IMPL *);
+
/*
* __wt_las_remove_block --
* Remove all records matching a key prefix from the lookaside store.
@@ -19,8 +21,7 @@ __wt_las_remove_block(WT_SESSION_IMPL *session,
WT_DECL_ITEM(las_addr);
WT_DECL_ITEM(las_key);
WT_DECL_RET;
- uint64_t las_counter, las_txnid;
- int64_t remove_cnt;
+ uint64_t las_counter, las_txnid, remove_cnt;
uint32_t las_id;
int exact;
@@ -74,7 +75,7 @@ err: __wt_scr_free(session, &las_addr);
if (remove_cnt > S2C(session)->las_record_cnt)
S2C(session)->las_record_cnt = 0;
else if (remove_cnt > 0)
- (void)__wt_atomic_subi64(
+ (void)__wt_atomic_sub64(
&S2C(session)->las_record_cnt, remove_cnt);
return (ret);
@@ -451,6 +452,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref)
*/
dsk = tmp.data;
if (F_ISSET(dsk, WT_PAGE_LAS_UPDATE) && __wt_las_is_written(session)) {
+ __btree_verbose_lookaside_read(session);
WT_STAT_CONN_INCR(session, cache_read_lookaside);
WT_STAT_DATA_INCR(session, cache_read_lookaside);
@@ -680,3 +682,43 @@ skip_evict:
__wt_sleep(0, sleep_cnt);
}
}
+
+/*
+ * __btree_verbose_lookaside_read --
+ * Create a verbose message to display at most once per checkpoint when
+ * performing a lookaside table read.
+ */
+static void
+__btree_verbose_lookaside_read(WT_SESSION_IMPL *session)
+{
+#ifdef HAVE_VERBOSE
+ WT_CONNECTION_IMPL *conn;
+ uint64_t ckpt_gen_current, ckpt_gen_last;
+
+ if (!WT_VERBOSE_ISSET(session, WT_VERB_LOOKASIDE)) return;
+
+ conn = S2C(session);
+ ckpt_gen_current = __wt_gen(session, WT_GEN_CHECKPOINT);
+ ckpt_gen_last = conn->las_verb_gen_read;
+
+ /*
+ * This message is throttled to one per checkpoint. To do this we
+ * track the generation of the last checkpoint for which the message
+ * was printed and check against the current checkpoint generation.
+ */
+ if (ckpt_gen_current > ckpt_gen_last) {
+ /*
+ * Attempt to atomically replace the last checkpoint generation
+ * for which this message was printed. If the atomic swap fails
+ * we have raced and the winning thread will print the message.
+ */
+ if (__wt_atomic_casv64(&conn->las_verb_gen_read,
+ ckpt_gen_last, ckpt_gen_current)) {
+ __wt_verbose(session, WT_VERB_LOOKASIDE,
+ "Read from lookaside file triggered.");
+ }
+ }
+#else
+ WT_UNUSED(session);
+#endif
+}