@@ -924,7 +924,7 @@ void TAPSessionStats::clearStats(const std::string &name) {
924
924
DcpConnMap::DcpConnMap (EventuallyPersistentEngine &e)
925
925
: ConnMap(e),
926
926
aggrDcpConsumerBufferSize (0 ) {
927
- numActiveSnoozingBackfills = 0 ;
927
+ backfills. numActiveSnoozing = 0 ;
928
928
updateMaxActiveSnoozingBackfills (engine.getEpStats ().getMaxDataSize ());
929
929
minCompressionRatioForProducer.store (
930
930
engine.getConfiguration ().getDcpMinCompressionRatio ());
@@ -1312,36 +1312,42 @@ void DcpConnMap::notifyBackfillManagerTasks() {
1312
1312
1313
1313
bool DcpConnMap::canAddBackfillToActiveQ ()
1314
1314
{
1315
- SpinLockHolder lh (&numBackfillsLock );
1316
- if (numActiveSnoozingBackfills < maxActiveSnoozingBackfills ) {
1317
- ++numActiveSnoozingBackfills ;
1315
+ std::lock_guard<std::mutex> lh (backfills. mutex );
1316
+ if (backfills. numActiveSnoozing < backfills. maxActiveSnoozing ) {
1317
+ ++backfills. numActiveSnoozing ;
1318
1318
return true ;
1319
1319
}
1320
1320
return false ;
1321
1321
}
1322
1322
1323
1323
void DcpConnMap::decrNumActiveSnoozingBackfills ()
1324
1324
{
1325
- SpinLockHolder lh (&numBackfillsLock);
1326
- if (numActiveSnoozingBackfills > 0 ) {
1327
- --numActiveSnoozingBackfills;
1328
- } else {
1329
- LOG (EXTENSION_LOG_WARNING, " ActiveSnoozingBackfills already zero!!!" );
1325
+ {
1326
+ std::lock_guard<std::mutex> lh (backfills.mutex );
1327
+ if (backfills.numActiveSnoozing > 0 ) {
1328
+ --backfills.numActiveSnoozing ;
1329
+ return ;
1330
+ }
1330
1331
}
1332
+ LOG (EXTENSION_LOG_WARNING, " ActiveSnoozingBackfills already zero!!!" );
1331
1333
}
1332
1334
1333
1335
void DcpConnMap::updateMaxActiveSnoozingBackfills (size_t maxDataSize)
1334
1336
{
1335
1337
double numBackfillsMemThresholdPercent =
1336
1338
static_cast <double >(numBackfillsMemThreshold)/100 ;
1337
1339
size_t max = maxDataSize * numBackfillsMemThresholdPercent / dbFileMem;
1338
- /* We must have atleast one active/snoozing backfill */
1339
- SpinLockHolder lh (&numBackfillsLock);
1340
- maxActiveSnoozingBackfills =
1341
- std::max (static_cast <size_t >(1 ),
1342
- std::min (max, static_cast <size_t >(numBackfillsThreshold)));
1340
+ uint16_t newMaxActive;
1341
+ {
1342
+ std::lock_guard<std::mutex> lh (backfills.mutex );
1343
+ /* We must have atleast one active/snoozing backfill */
1344
+ backfills.maxActiveSnoozing =
1345
+ std::max (static_cast <size_t >(1 ),
1346
+ std::min (max, static_cast <size_t >(numBackfillsThreshold)));
1347
+ newMaxActive = backfills.maxActiveSnoozing ;
1348
+ }
1343
1349
LOG (EXTENSION_LOG_DEBUG, " Max active snoozing backfills set to %d" ,
1344
- maxActiveSnoozingBackfills );
1350
+ newMaxActive );
1345
1351
}
1346
1352
1347
1353
void DcpConnMap::addStats (ADD_STAT add_stat, const void *c) {
0 commit comments