Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-12938

[Server] cleanupOrphaned example could include success print and optional sleep

    XMLWordPrintableJSON

Details

    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.)

      Attachments

        Activity

          People

            alison.huh@mongodb.com Alison Huh
            nicholas.cottrell@mongodb.com Nic Cottrell
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 2 days ago