summaryrefslogtreecommitdiff
path: root/src/btree/bt_read.c
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-11-23 17:49:23 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2015-11-23 17:49:23 +1100
commite064ff4d434cb4903941e0a7f47d700765e408a4 (patch)
tree351aaff3a00cb950b1170cf01bd2228ca1419c90 /src/btree/bt_read.c
parent2d01a566ba7b3576cb5b45af55479b3c06995589 (diff)
downloadmongo-e064ff4d434cb4903941e0a7f47d700765e408a4.tar.gz
SERVER-21585 Clean up LAS based on the current count of inserted records.
Diffstat (limited to 'src/btree/bt_read.c')
-rw-r--r--src/btree/bt_read.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c
index 389ac761c5b..18fd87e78ff 100644
--- a/src/btree/bt_read.c
+++ b/src/btree/bt_read.c
@@ -20,9 +20,12 @@ __wt_las_remove_block(WT_SESSION_IMPL *session,
WT_DECL_ITEM(las_key);
WT_DECL_RET;
uint64_t las_counter, las_txnid;
+ int64_t remove_cnt;
uint32_t las_id;
int exact;
+ remove_cnt = 0;
+
WT_ERR(__wt_scr_alloc(session, 0, &las_addr));
WT_ERR(__wt_scr_alloc(session, 0, &las_key));
@@ -56,11 +59,24 @@ __wt_las_remove_block(WT_SESSION_IMPL *session,
* remains positioned in that case.
*/
WT_ERR(cursor->remove(cursor));
+ ++remove_cnt;
}
WT_ERR_NOTFOUND_OK(ret);
err: __wt_scr_free(session, &las_addr);
__wt_scr_free(session, &las_key);
+
+ /*
+ * If there were races to remove records, we can over-count. All
+ * arithmetic is signed, so underflow isn't fatal, but check anyway so
+ * we don't skew low over time.
+ */
+ if (remove_cnt > S2C(session)->las_record_cnt)
+ S2C(session)->las_record_cnt = 0;
+ else if (remove_cnt > 0)
+ (void)__wt_atomic_subi64(
+ &S2C(session)->las_record_cnt, remove_cnt);
+
return (ret);
}