[DOCS-12938] [Server] cleanupOrphaned example could include success print and optional sleep Created: 02/Aug/19  Updated: 30/Oct/23  Resolved: 06/Feb/23

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Critical - P2
Reporter: Nic Cottrell Assignee: Alison Huh
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-4723 Check for failure in cleanupOrphaned ... Closed
Participants:
Days since reply: 1 year, 2 days ago

 Description   

Description

I'm looking at https://docs.mongodb.com/manual/reference/command/cleanupOrphaned/#remove-all-orphaned-documents-from-a-shard

When put inside a script to run via the Mongo shell, it would be good to:
(1) print something to confirm that all the keys have been checked
(2) allow some sleep to slow down the loop and reduce any performance impact.

I suggest something like:

var loopSleep = 100; // milliseconds
var nextKey = { };
var result;
 
while ( nextKey != null ) {
  result = db.adminCommand( { cleanupOrphaned: "test.user", startingFromKey: nextKey } );
 
  if (result.ok != 1)
     print("Unable to complete at this time: failure or timeout.");
 
  printjson(result);
 
  nextKey = result.stoppedAtKey;
 
  if (loopSleep > 0) sleep(loopSleep); // allow tuning of performance impact
}
 
print("Orphan cleanup complete.");

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Nic Cottrell [ 06/Feb/23 ]

LGTM

Comment by Nic Cottrell [ 29/Sep/20 ]

linda.qin josef.ahmad - do either of you sharding experts have any thoughts on this? Are you OK with making these changes to the docs, or do you think it's better to make a KBA about cleaning up orphans and putting this there instead? 

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