/
vbucket.cc
701 lines (612 loc) · 22.2 KB
/
vbucket.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2015 Couchbase, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "config.h"
#include <functional>
#include <list>
#include <set>
#include <string>
#include <vector>
#include "atomic.h"
#include "bgfetcher.h"
#include "ep_engine.h"
#define STATWRITER_NAMESPACE vbucket
#include "statwriter.h"
#undef STATWRITER_NAMESPACE
#include "vbucket.h"
VBucketFilter VBucketFilter::filter_diff(const VBucketFilter &other) const {
std::vector<uint16_t> tmp(acceptable.size() + other.size());
std::vector<uint16_t>::iterator end;
end = std::set_symmetric_difference(acceptable.begin(),
acceptable.end(),
other.acceptable.begin(),
other.acceptable.end(),
tmp.begin());
return VBucketFilter(std::vector<uint16_t>(tmp.begin(), end));
}
VBucketFilter VBucketFilter::filter_intersection(const VBucketFilter &other)
const {
std::vector<uint16_t> tmp(acceptable.size() + other.size());
std::vector<uint16_t>::iterator end;
end = std::set_intersection(acceptable.begin(), acceptable.end(),
other.acceptable.begin(),
other.acceptable.end(),
tmp.begin());
return VBucketFilter(std::vector<uint16_t>(tmp.begin(), end));
}
static bool isRange(std::set<uint16_t>::const_iterator it,
const std::set<uint16_t>::const_iterator &end,
size_t &length)
{
length = 0;
for (uint16_t val = *it;
it != end && (val + length) == *it;
++it, ++length) {
// empty
}
--length;
return length > 1;
}
std::ostream& operator <<(std::ostream &out, const VBucketFilter &filter)
{
std::set<uint16_t>::const_iterator it;
if (filter.acceptable.empty()) {
out << "{ empty }";
} else {
bool needcomma = false;
out << "{ ";
for (it = filter.acceptable.begin();
it != filter.acceptable.end();
++it) {
if (needcomma) {
out << ", ";
}
size_t length;
if (isRange(it, filter.acceptable.end(), length)) {
std::set<uint16_t>::iterator last = it;
for (size_t i = 0; i < length; ++i) {
++last;
}
out << "[" << *it << "," << *last << "]";
it = last;
} else {
out << *it;
}
needcomma = true;
}
out << " }";
}
return out;
}
std::atomic<size_t> VBucket::chkFlushTimeout(MIN_CHK_FLUSH_TIMEOUT);
const vbucket_state_t VBucket::ACTIVE =
static_cast<vbucket_state_t>(htonl(vbucket_state_active));
const vbucket_state_t VBucket::REPLICA =
static_cast<vbucket_state_t>(htonl(vbucket_state_replica));
const vbucket_state_t VBucket::PENDING =
static_cast<vbucket_state_t>(htonl(vbucket_state_pending));
const vbucket_state_t VBucket::DEAD =
static_cast<vbucket_state_t>(htonl(vbucket_state_dead));
VBucket::~VBucket() {
if (!pendingOps.empty() || !pendingBGFetches.empty()) {
LOG(EXTENSION_LOG_WARNING,
"Have %ld pending ops and %ld pending reads "
"while destroying vbucket\n",
pendingOps.size(), pendingBGFetches.size());
}
stats.decrDiskQueueSize(dirtyQueueSize.load());
size_t num_pending_fetches = 0;
vb_bgfetch_queue_t::iterator itr = pendingBGFetches.begin();
for (; itr != pendingBGFetches.end(); ++itr) {
vb_bgfetch_item_ctx_t &bg_itm_ctx = itr->second;
std::list<VBucketBGFetchItem *> &bgitems = bg_itm_ctx.bgfetched_list;
std::list<VBucketBGFetchItem *>::iterator vit = bgitems.begin();
for (; vit != bgitems.end(); ++vit) {
delete (*vit);
++num_pending_fetches;
}
}
stats.numRemainingBgJobs.fetch_sub(num_pending_fetches);
pendingBGFetches.clear();
delete failovers;
// Clear out the bloomfilter(s)
clearFilter();
stats.memOverhead.fetch_sub(sizeof(VBucket) + ht.memorySize() +
sizeof(CheckpointManager));
LOG(EXTENSION_LOG_INFO, "Destroying vbucket %d\n", id);
}
void VBucket::fireAllOps(EventuallyPersistentEngine &engine,
ENGINE_ERROR_CODE code) {
LockHolder lh(pendingOpLock);
if (pendingOpsStart > 0) {
hrtime_t now = gethrtime();
if (now > pendingOpsStart) {
hrtime_t d = (now - pendingOpsStart) / 1000;
stats.pendingOpsHisto.add(d);
atomic_setIfBigger(stats.pendingOpsMaxDuration, d);
}
} else {
return;
}
pendingOpsStart = 0;
stats.pendingOps.fetch_sub(pendingOps.size());
atomic_setIfBigger(stats.pendingOpsMax, pendingOps.size());
while (!pendingOps.empty()) {
const void *pendingOperation = pendingOps.back();
pendingOps.pop_back();
// We don't want to hold the pendingOpLock when
// calling notifyIOComplete.
lh.unlock();
engine.notifyIOComplete(pendingOperation, code);
lh.lock();
}
LOG(EXTENSION_LOG_INFO,
"Fired pendings ops for vbucket %" PRIu16 " in state %s\n",
id, VBucket::toString(state));
}
void VBucket::fireAllOps(EventuallyPersistentEngine &engine) {
if (state == vbucket_state_active) {
fireAllOps(engine, ENGINE_SUCCESS);
} else if (state == vbucket_state_pending) {
// Nothing
} else {
fireAllOps(engine, ENGINE_NOT_MY_VBUCKET);
}
}
void VBucket::setState(vbucket_state_t to) {
vbucket_state_t oldstate;
{
WriterLockHolder wlh(stateLock);
oldstate = state;
if (to == vbucket_state_active &&
checkpointManager.getOpenCheckpointId() < 2) {
checkpointManager.setOpenCheckpointId(2);
}
LOG(EXTENSION_LOG_NOTICE,
"VBucket::setState: transitioning vbucket:%" PRIu16 " from:%s to:%s",
id, VBucket::toString(oldstate), VBucket::toString(to));
state = to;
}
}
vbucket_state VBucket::getVBucketState() const {
auto persisted_range = getPersistedSnapshot();
return vbucket_state{getState(),
getPersistenceCheckpointId(), 0, getHighSeqno(),
getPurgeSeqno(),
persisted_range.start, persisted_range.end,
getMaxCas(), failovers->toJSON()};
}
void VBucket::doStatsForQueueing(const Item& qi, size_t itemBytes)
{
++dirtyQueueSize;
dirtyQueueMem.fetch_add(sizeof(Item));
++dirtyQueueFill;
dirtyQueueAge.fetch_add(qi.getQueuedTime());
dirtyQueuePendingWrites.fetch_add(itemBytes);
}
void VBucket::doStatsForFlushing(Item& qi, size_t itemBytes)
{
decrDirtyQueueSize(1);
decrDirtyQueueMem(sizeof(Item));
++dirtyQueueDrain;
decrDirtyQueueAge(qi.getQueuedTime());
decrDirtyQueuePendingWrites(itemBytes);
}
void VBucket::incrMetaDataDisk(Item& qi)
{
metaDataDisk.fetch_add(qi.getNKey() + sizeof(ItemMetaData));
}
void VBucket::decrMetaDataDisk(Item& qi)
{
// assume couchstore remove approx this much data from disk
metaDataDisk.fetch_sub((qi.getNKey() + sizeof(ItemMetaData)));
}
void VBucket::resetStats() {
opsCreate.store(0);
opsUpdate.store(0);
opsDelete.store(0);
opsReject.store(0);
stats.decrDiskQueueSize(dirtyQueueSize.load());
dirtyQueueSize.store(0);
dirtyQueueMem.store(0);
dirtyQueueFill.store(0);
dirtyQueueAge.store(0);
dirtyQueuePendingWrites.store(0);
dirtyQueueDrain.store(0);
fileSpaceUsed = 0;
fileSize = 0;
}
template <typename T>
void VBucket::addStat(const char *nm, const T &val, ADD_STAT add_stat,
const void *c) {
std::string stat = statPrefix;
if (nm != NULL) {
add_prefixed_stat(statPrefix, nm, val, add_stat, c);
} else {
add_casted_stat(statPrefix.data(), val, add_stat, c);
}
}
size_t VBucket::queueBGFetchItem(const std::string &key,
VBucketBGFetchItem *fetch,
BgFetcher *bgFetcher) {
LockHolder lh(pendingBGFetchesLock);
vb_bgfetch_item_ctx_t& bgfetch_itm_ctx = pendingBGFetches[key];
if (bgfetch_itm_ctx.bgfetched_list.empty()) {
bgfetch_itm_ctx.isMetaOnly = true;
}
bgfetch_itm_ctx.bgfetched_list.push_back(fetch);
if (!fetch->metaDataOnly) {
bgfetch_itm_ctx.isMetaOnly = false;
}
bgFetcher->addPendingVB(id);
return pendingBGFetches.size();
}
bool VBucket::getBGFetchItems(vb_bgfetch_queue_t &fetches) {
LockHolder lh(pendingBGFetchesLock);
fetches.insert(pendingBGFetches.begin(), pendingBGFetches.end());
pendingBGFetches.clear();
return fetches.size() > 0;
}
void VBucket::addHighPriorityVBEntry(uint64_t id, const void *cookie,
bool isBySeqno) {
LockHolder lh(hpChksMutex);
if (shard) {
++shard->highPriorityCount;
}
hpChks.push_back(HighPriorityVBEntry(cookie, id, isBySeqno));
numHpChks.store(hpChks.size());
}
void VBucket::notifyOnPersistence(EventuallyPersistentEngine &e,
uint64_t idNum,
bool isBySeqno) {
LockHolder lh(hpChksMutex);
std::map<const void*, ENGINE_ERROR_CODE> toNotify;
std::list<HighPriorityVBEntry>::iterator entry = hpChks.begin();
std::string logStr(isBySeqno
? "seqno persistence"
: "checkpoint persistence");
while (entry != hpChks.end()) {
if (isBySeqno != entry->isBySeqno_) {
++entry;
continue;
}
std::string logStr(isBySeqno ?
"seqno persistence" :
"checkpoint persistence");
hrtime_t wall_time(gethrtime() - entry->start);
size_t spent = wall_time / 1000000000;
if (entry->id <= idNum) {
toNotify[entry->cookie] = ENGINE_SUCCESS;
stats.chkPersistenceHisto.add(wall_time / 1000);
adjustCheckpointFlushTimeout(wall_time / 1000000000);
LOG(EXTENSION_LOG_NOTICE, "Notified the completion of %s "
"for vbucket %" PRIu16 ", Check for: %" PRIu64 ", "
"Persisted upto: %" PRIu64 ", cookie %p",
logStr.c_str(), id, entry->id, idNum, entry->cookie);
entry = hpChks.erase(entry);
if (shard) {
--shard->highPriorityCount;
}
} else if (spent > getCheckpointFlushTimeout()) {
adjustCheckpointFlushTimeout(spent);
e.storeEngineSpecific(entry->cookie, NULL);
toNotify[entry->cookie] = ENGINE_TMPFAIL;
LOG(EXTENSION_LOG_WARNING, "Notified the timeout on %s "
"for vbucket %" PRIu16 ", Check for: %" PRIu64 ", "
"Persisted upto: %" PRIu64 ", cookie %p",
logStr.c_str(), id, entry->id, idNum, entry->cookie);
entry = hpChks.erase(entry);
if (shard) {
--shard->highPriorityCount;
}
} else {
++entry;
}
}
numHpChks.store(hpChks.size());
lh.unlock();
std::map<const void*, ENGINE_ERROR_CODE>::iterator itr = toNotify.begin();
for (; itr != toNotify.end(); ++itr) {
e.notifyIOComplete(itr->first, itr->second);
}
}
void VBucket::notifyAllPendingConnsFailed(EventuallyPersistentEngine &e) {
LockHolder lh(hpChksMutex);
std::map<const void*, ENGINE_ERROR_CODE> toNotify;
std::list<HighPriorityVBEntry>::iterator entry = hpChks.begin();
while (entry != hpChks.end()) {
toNotify[entry->cookie] = ENGINE_TMPFAIL;
e.storeEngineSpecific(entry->cookie, NULL);
entry = hpChks.erase(entry);
if (shard) {
--shard->highPriorityCount;
}
}
lh.unlock();
std::map<const void*, ENGINE_ERROR_CODE>::iterator itr = toNotify.begin();
for (; itr != toNotify.end(); ++itr) {
e.notifyIOComplete(itr->first, itr->second);
}
fireAllOps(e);
}
void VBucket::adjustCheckpointFlushTimeout(size_t wall_time) {
size_t middle = (MIN_CHK_FLUSH_TIMEOUT + MAX_CHK_FLUSH_TIMEOUT) / 2;
if (wall_time <= MIN_CHK_FLUSH_TIMEOUT) {
chkFlushTimeout = MIN_CHK_FLUSH_TIMEOUT;
} else if (wall_time <= middle) {
chkFlushTimeout = middle;
} else {
chkFlushTimeout = MAX_CHK_FLUSH_TIMEOUT;
}
}
size_t VBucket::getHighPriorityChkSize() {
return numHpChks.load();
}
size_t VBucket::getCheckpointFlushTimeout() {
return chkFlushTimeout;
}
size_t VBucket::getNumItems(item_eviction_policy_t policy) {
if (policy == VALUE_ONLY) {
return ht.getNumInMemoryItems();
} else {
return ht.getNumItems();
}
}
size_t VBucket::getNumNonResidentItems(item_eviction_policy_t policy) {
if (policy == VALUE_ONLY) {
return ht.getNumInMemoryNonResItems();
} else {
size_t num_items = ht.getNumItems();
size_t num_res_items = ht.getNumInMemoryItems() -
ht.getNumInMemoryNonResItems();
return num_items > num_res_items ? (num_items - num_res_items) : 0;
}
}
uint64_t VBucket::getPersistenceCheckpointId() const {
return persistenceCheckpointId.load();
}
void VBucket::setPersistenceCheckpointId(uint64_t checkpointId) {
persistenceCheckpointId.store(checkpointId);
}
bool VBucket::isResidentRatioUnderThreshold(float threshold,
item_eviction_policy_t policy) {
if (policy != FULL_EVICTION) {
throw std::invalid_argument("VBucket::isResidentRatioUnderThreshold: "
"policy (which is " + std::to_string(policy) +
") must be FULL_EVICTION");
}
size_t num_items = getNumItems(policy);
size_t num_non_resident_items = getNumNonResidentItems(policy);
if (threshold >= ((float)(num_items - num_non_resident_items) /
num_items)) {
return true;
} else {
return false;
}
}
void VBucket::createFilter(size_t key_count, double probability) {
// Create the actual bloom filter upon vbucket creation during
// scenarios:
// - Bucket creation
// - Rebalance
LockHolder lh(bfMutex);
if (bFilter == nullptr && tempFilter == nullptr) {
bFilter = new BloomFilter(key_count, probability, BFILTER_ENABLED);
} else {
LOG(EXTENSION_LOG_WARNING, "(vb %" PRIu16 ") Bloom filter / Temp filter"
" already exist!", id);
}
}
void VBucket::initTempFilter(size_t key_count, double probability) {
// Create a temp bloom filter with status as COMPACTING,
// if the main filter is found to exist, set its state to
// COMPACTING as well.
LockHolder lh(bfMutex);
if (tempFilter) {
delete tempFilter;
}
tempFilter = new BloomFilter(key_count, probability, BFILTER_COMPACTING);
if (bFilter) {
bFilter->setStatus(BFILTER_COMPACTING);
}
}
void VBucket::addToFilter(const std::string &key) {
LockHolder lh(bfMutex);
if (bFilter) {
bFilter->addKey(key.c_str(), key.length());
}
// If the temp bloom filter is not found to be NULL,
// it means that compaction is running on the particular
// vbucket. Therefore add the key to the temp filter as
// well, as once compaction completes the temp filter
// will replace the main bloom filter.
if (tempFilter) {
tempFilter->addKey(key.c_str(), key.length());
}
}
bool VBucket::maybeKeyExistsInFilter(const std::string &key) {
LockHolder lh(bfMutex);
if (bFilter) {
return bFilter->maybeKeyExists(key.c_str(), key.length());
} else {
// If filter doesn't exist, allow the BgFetch to go through.
return true;
}
}
bool VBucket::isTempFilterAvailable() {
LockHolder lh(bfMutex);
if (tempFilter &&
(tempFilter->getStatus() == BFILTER_COMPACTING ||
tempFilter->getStatus() == BFILTER_ENABLED)) {
return true;
} else {
return false;
}
}
void VBucket::addToTempFilter(const std::string &key) {
// Keys will be added to only the temp filter during
// compaction.
LockHolder lh(bfMutex);
if (tempFilter) {
tempFilter->addKey(key.c_str(), key.length());
}
}
void VBucket::swapFilter() {
// Delete the main bloom filter and replace it with
// the temp filter that was populated during compaction,
// only if the temp filter's state is found to be either at
// COMPACTING or ENABLED (if in the case the user enables
// bloomfilters for some reason while compaction was running).
// Otherwise, it indicates that the filter's state was
// possibly disabled during compaction, therefore clear out
// the temp filter. If it gets enabled at some point, a new
// bloom filter will be made available after the next
// compaction.
LockHolder lh(bfMutex);
if (bFilter && tempFilter) {
delete bFilter;
bFilter = NULL;
}
if (tempFilter &&
(tempFilter->getStatus() == BFILTER_COMPACTING ||
tempFilter->getStatus() == BFILTER_ENABLED)) {
bFilter = tempFilter;
tempFilter = NULL;
bFilter->setStatus(BFILTER_ENABLED);
} else if (tempFilter) {
delete tempFilter;
tempFilter = NULL;
}
}
void VBucket::clearFilter() {
LockHolder lh(bfMutex);
if (bFilter) {
delete bFilter;
bFilter = NULL;
}
if (tempFilter) {
delete tempFilter;
tempFilter = NULL;
}
}
void VBucket::setFilterStatus(bfilter_status_t to) {
LockHolder lh(bfMutex);
if (bFilter) {
bFilter->setStatus(to);
}
if (tempFilter) {
tempFilter->setStatus(to);
}
}
std::string VBucket::getFilterStatusString() {
LockHolder lh(bfMutex);
if (bFilter) {
return bFilter->getStatusString();
} else if (tempFilter) {
return tempFilter->getStatusString();
} else {
return "DOESN'T EXIST";
}
}
size_t VBucket::getFilterSize() {
LockHolder lh(bfMutex);
if (bFilter) {
return bFilter->getFilterSize();
} else {
return 0;
}
}
size_t VBucket::getNumOfKeysInFilter() {
LockHolder lh(bfMutex);
if (bFilter) {
return bFilter->getNumOfKeysInFilter();
} else {
return 0;
}
}
void VBucket::addStats(bool details, ADD_STAT add_stat, const void *c,
item_eviction_policy_t policy) {
addStat(NULL, toString(state), add_stat, c);
if (details) {
size_t numItems = getNumItems(policy);
size_t tempItems = getNumTempItems();
addStat("num_items", numItems, add_stat, c);
addStat("num_temp_items", tempItems, add_stat, c);
addStat("num_non_resident", getNumNonResidentItems(policy),
add_stat, c);
addStat("ht_memory", ht.memorySize(), add_stat, c);
addStat("ht_item_memory", ht.getItemMemory(), add_stat, c);
addStat("ht_cache_size", ht.cacheSize.load(), add_stat, c);
addStat("num_ejects", ht.getNumEjects(), add_stat, c);
addStat("ops_create", opsCreate.load(), add_stat, c);
addStat("ops_update", opsUpdate.load(), add_stat, c);
addStat("ops_delete", opsDelete.load(), add_stat, c);
addStat("ops_reject", opsReject.load(), add_stat, c);
addStat("queue_size", dirtyQueueSize.load(), add_stat, c);
addStat("queue_memory", dirtyQueueMem.load(), add_stat, c);
addStat("queue_fill", dirtyQueueFill.load(), add_stat, c);
addStat("queue_drain", dirtyQueueDrain.load(), add_stat, c);
addStat("queue_age", getQueueAge(), add_stat, c);
addStat("pending_writes", dirtyQueuePendingWrites.load(), add_stat, c);
addStat("db_data_size", fileSpaceUsed.load(), add_stat, c);
addStat("db_file_size", fileSize.load(), add_stat, c);
addStat("high_seqno", getHighSeqno(), add_stat, c);
addStat("uuid", failovers->getLatestUUID(), add_stat, c);
addStat("purge_seqno", getPurgeSeqno(), add_stat, c);
addStat("bloom_filter", getFilterStatusString().data(),
add_stat, c);
addStat("bloom_filter_size", getFilterSize(), add_stat, c);
addStat("bloom_filter_key_count", getNumOfKeysInFilter(), add_stat, c);
addStat("rollback_item_count", getRollbackItemCount(), add_stat, c);
hlc.addStats(statPrefix, add_stat, c);
}
}
void VBucket::decrDirtyQueueMem(size_t decrementBy)
{
size_t oldVal, newVal;
do {
oldVal = dirtyQueueMem.load(std::memory_order_relaxed);
if (oldVal < decrementBy) {
newVal = 0;
} else {
newVal = oldVal - decrementBy;
}
} while (!dirtyQueueMem.compare_exchange_strong(oldVal, newVal));
}
void VBucket::decrDirtyQueueAge(uint32_t decrementBy)
{
uint64_t oldVal, newVal;
do {
oldVal = dirtyQueueAge.load(std::memory_order_relaxed);
if (oldVal < decrementBy) {
newVal = 0;
} else {
newVal = oldVal - decrementBy;
}
} while (!dirtyQueueAge.compare_exchange_strong(oldVal, newVal));
}
void VBucket::decrDirtyQueuePendingWrites(size_t decrementBy)
{
size_t oldVal, newVal;
do {
oldVal = dirtyQueuePendingWrites.load(std::memory_order_relaxed);
if (oldVal < decrementBy) {
newVal = 0;
} else {
newVal = oldVal - decrementBy;
}
} while (!dirtyQueuePendingWrites.compare_exchange_strong(oldVal, newVal));
}