Permalink
Browse files

Bug 2777: Don't access queue->size() without holding the queue lock

Change-Id: I72582d40f49caa2c0936d41e7ca759e8999a9b57
Reviewed-on: http://review.membase.org/3379
Tested-by: Matt Ingenthron <matt@northscale.com>
Reviewed-by: Matt Ingenthron <matt@northscale.com>
  • Loading branch information...
1 parent 920b179 commit 741a593bf33c240963c8e42081dc0aa9178eb629 @trondn trondn committed with Matt Ingenthron Oct 25, 2010
Showing with 9 additions and 3 deletions.
  1. +4 −3 ep_engine.cc
  2. +5 −0 tapconnection.hh
View
@@ -2011,7 +2011,10 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doTapStats(const void *cookie,
for (iter = allTaps.begin(); iter != allTaps.end(); iter++) {
totalTaps++;
TapConnection *tc = *iter;
- addTapStat("qlen", tc, tc->queue->size(), add_stat, cookie);
+ size_t qlen = tc->getQueueSize();
+ tap_queue += qlen;
+
+ addTapStat("qlen", tc, qlen, add_stat, cookie);
addTapStat("qlen_high_pri", tc, tc->vBucketHighPriority.size(), add_stat, cookie);
addTapStat("qlen_low_pri", tc, tc->vBucketLowPriority.size(), add_stat, cookie);
addTapStat("vb_filters", tc, tc->vbucketFilter.size(), add_stat, cookie);
@@ -2043,8 +2046,6 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doTapStats(const void *cookie,
addTapStat("backfill_age", tc, (size_t)tc->backfillAge, add_stat, cookie);
}
- tap_queue += tc->queue->size();
-
if (tc->ackSupported) {
addTapStat("ack_seqno", tc, tc->seqno, add_stat, cookie);
addTapStat("recv_ack_seqno", tc, tc->seqnoReceived,
View
@@ -258,6 +258,11 @@ private:
+ (bgJobIssued - bgJobCompleted) + queue->size();
}
+ size_t getQueueSize() {
+ SpinLockHolder lh(&queueLock);
+ return queue->size();
+ }
+
Item* nextFetchedItem();
void flush() {

0 comments on commit 741a593

Please sign in to comment.