[SERVER-8149] Add optional 'max' option to db command 'convertToCapped' Created: 11/Jan/13  Updated: 06/Dec/22  Resolved: 04/Mar/19

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

Type: Improvement Priority: Major - P3
Reporter: Samuel Chou Assignee: Backlog - Storage Execution Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Participants:

 Description   

We rely on both the 'size' and 'max' options for a particular capped collection in our application. We also allow configuration changes to the 'max' option. When this happens, we drop and re-create the capped collection with the new 'max' option.

The problem is that we have a lot of other programs that are always inserting lots of data to this collection... so in between the drop and create, if an insert occurs, our collection is no longer capped:

my $cmd = Tie::IxHash->new(create => "Logs", capped => boolean::true, size => MAX_CAPPED_SIZE, max => $max_msgs);
$db->run_command(Tie::IxHash->new(drop => 'Logs'));
$db->run_command($cmd);

The only solution I could find was the 'convertToCapped' database command, which would help us by locking the collection while converting. However, this command doesn't support the 'max' option.

Another solution would be the ability to drop and create a collection atomically (i.e. one database command instead of two), since the 'create' command supports the max 'option'


Generated at Thu Feb 08 03:16:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.