Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28913

[v3.2] BackgroundSync::consume() should check result of BlockingQueue::blockingPop() before decrementing server metrics

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.12
    • Replication
    • None
    • Replication
    • ALL
    • 0

    Description

      In 3.2, BackgroundSync::consume may erroneously decrement the following server status metrics when BlockingQueue::blockingPop() returns an empty document:

      "repl.buffer.count"
      "repl.buffer.sizeBytes"

      https://github.com/mongodb/mongo/blob/f98bd7d1a376ab741024d21e20e4b1b48d9a0af6/src/mongo/db/repl/bgsync.cpp#L840

      bgsync.cpp

      837
      void BackgroundSync::consume() {
      838
          // this is just to get the op off the queue, it's been peeked at
      839
          // and queued for application already
      840
          BSONObj op = _buffer.blockingPop();
      841
          bufferCountGauge.decrement(1);
      842
          bufferSizeGauge.decrement(getSize(op));
      843
      }
      

      https://github.com/mongodb/mongo/blob/f98bd7d1a376ab741024d21e20e4b1b48d9a0af6/src/mongo/util/queue.h#L171

      queue.h

      165
          T blockingPop() {
      166
              stdx::unique_lock<stdx::mutex> lk(_lock);
      167
              _clearing = false;
      168
              while (_queue.empty() && !_clearing)
      169
                  _cvNoLongerEmpty.wait(lk);
      170
              if (_clearing) {
      171
                  return T{};
      172
              }
      173
       
      174
              T t = _queue.front();
      175
              _queue.pop();
      176
              _currentSize -= _getSize(t);
      177
              _cvNoLongerFull.notify_one();
      178
       
      179
              return t;
      180
          }
      

      Attachments

        Activity

          People

            backlog-server-repl Backlog - Replication Team
            benety.goh@mongodb.com Benety Goh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: