@@ -924,7 +924,7 @@ void TAPSessionStats::clearStats(const std::string &name) {
924924DcpConnMap::DcpConnMap (EventuallyPersistentEngine &e)
925925 : ConnMap(e),
926926 aggrDcpConsumerBufferSize (0 ) {
927- numActiveSnoozingBackfills = 0 ;
927+ backfills. numActiveSnoozing = 0 ;
928928 updateMaxActiveSnoozingBackfills (engine.getEpStats ().getMaxDataSize ());
929929 minCompressionRatioForProducer.store (
930930 engine.getConfiguration ().getDcpMinCompressionRatio ());
@@ -1312,36 +1312,42 @@ void DcpConnMap::notifyBackfillManagerTasks() {
13121312
13131313bool DcpConnMap::canAddBackfillToActiveQ ()
13141314{
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 ;
13181318 return true ;
13191319 }
13201320 return false ;
13211321}
13221322
13231323void DcpConnMap::decrNumActiveSnoozingBackfills ()
13241324{
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+ }
13301331 }
1332+ LOG (EXTENSION_LOG_WARNING, " ActiveSnoozingBackfills already zero!!!" );
13311333}
13321334
13331335void DcpConnMap::updateMaxActiveSnoozingBackfills (size_t maxDataSize)
13341336{
13351337 double numBackfillsMemThresholdPercent =
13361338 static_cast <double >(numBackfillsMemThreshold)/100 ;
13371339 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+ }
13431349 LOG (EXTENSION_LOG_DEBUG, " Max active snoozing backfills set to %d" ,
1344- maxActiveSnoozingBackfills );
1350+ newMaxActive );
13451351}
13461352
13471353void DcpConnMap::addStats (ADD_STAT add_stat, const void *c) {
0 commit comments