[SERVER-40049] Make OplogBuffer use ProducerConsumerQueue instead of BlockingQueue Created: 08/Mar/19  Updated: 22/Aug/23  Resolved: 22/Aug/23

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

Type: Improvement Priority: Major - P3
Reporter: Matthew Russotto 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:
Related
related to SERVER-39950 Merge two oplog batching code paths Closed
is related to SERVER-40047 Test for blocking queue should not te... Closed
Assigned Teams:
Replication
Participants:

 Description   

The replication oplog buffer is the last and only user of BlockingQueue in https://github.com/mongodb/mongo/blob/master/src/mongo/util/queue.h

It would be better if we could switch to the ProducerConsumerQueue in https://github.com/mongodb/mongo/blob/master/src/mongo/util/producer_consumer_queue.h, which is used elsewhere in the code.



 Comments   
Comment by Eric Milkie [ 12/Feb/20 ]

Yeah sorry – those particular things were the original reasons that triggered me to write my own custom thread-safe queue in the first place..

Comment by Matthew Russotto [ 12/Feb/20 ]

Looks like queue.h may survive a bit longer. PCQ is missing some things – waitForSpace, clear, count of items in queue. Some of these are easy to add but I think clear() doesn't really fit with the way PCQ wants to do things.

Comment by Matthew Russotto [ 12/Feb/20 ]

If we want to backport this to 4.2, we will need to backport SERVER-42997 also.

Comment by Eric Milkie [ 05/Feb/20 ]

I'm just impressed that a class I wrote back in 2012 is still in use even today! I certainly didn't expect it to last this long..

commit f31d4d9acaee1e11f2ff0f1e84929ffb684ae053
Author: Eric Milkie <milkie@10gen.com>
Date: Mon Apr 30 11:26:55 2012 -0400

implement max-size thread-safe queue class

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