[SERVER-28913] [v3.2] BackgroundSync::consume() should check result of BlockingQueue::blockingPop() before decrementing server metrics Created: 21/Apr/17  Updated: 06/Dec/22  Resolved: 09/Apr/20

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 3.2.12
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Benety Goh Assignee: Backlog - Replication Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Replication
Operating System: ALL
Participants:
Linked BF Score: 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
    }



 Comments   
Comment by Siyuan Zhou [ 09/Apr/20 ]

3.2 is End of Life. Closing the ticket.

Generated at Thu Feb 08 04:19:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.