Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7548917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:49:07+00:00 2026-05-30T09:49:07+00:00

I have a 200gb data base on a sharded four node cluster and and

  • 0

I have a 200gb data base on a sharded four node cluster and and I would like to drop the databse and delet all the files associated to it from the node. I am connecting to my mongos and call dropDatabase on it. The system comes back with ok but if call show dbs, it will show the database again and shows that it is still occupying the 200gb. What I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:49:09+00:00Added an answer on May 30, 2026 at 9:49 am

    I think you are running into this issue:

    https://jira.mongodb.org/browse/SERVER-4804

    In most cases it seems like the database is in fact removed but the mongos still reports it as being there. You can verify it is gone by either trying to use the DB and getting an error or by logging into the shards directly and checking.

    The bug refers to issues with dropping databases while a migration is happening. You can workaround the cause of the issue by doing something like this (sub in your own dbname):

    mongos> use config
    switched to db config
    
    // 1. stop the balancer
    mongos> db.settings.update({_id: "balancer"}, {$set: {stopped: true}}, true)
    
    // 2. wait for in-progress migrations to finish, this may take a few seconds
    mongos> while (db.locks.findOne({_id: "balancer", state: {$ne: 0}}) != null) { sleep(1000); }
    
    // 3. now you can safely drop the database
    mongos> use <dbname>
    switched to db <dbname>
    mongos> db.dropDatabase()
    { "dropped" : "<dbname>", "ok" : 1 }
    

    You may want to run the flushRouterConfig on the mongoses to refresh the config info:

    mongos> use config
    switched to db config
    mongos> var mongoses = db.mongos.find()
    mongos> while (mongoses.hasNext()) { new Mongo(mongoses.next()._id).getDB("admin").runCommand({flushRouterConfig: 1}) }
    { "flushed" : true, "ok" : 1 }
    

    Of course, the real fix will only come along when the fix is committed – looks like it is targeted for 2.1

    If you are in a broken state, you can try this, but it is tricky:

    To “reset” the sharding metadata to recover from this issue, please try to do the following

    First, stop the balancer (as above) and wait for migrations to finish (also as above)
    Next, ensure there is no activity from the app servers on the database in question

    Now, ensure that there are no collection entries in config.collections for namespaces beginning with “TestCollection.” If so, remove those entries through a mongos:

    mongos> use config
    mongos> db.collections.find({_id: /^TestCollection\./})
    // if any records found, delete them
    mongos> db.collections.remove({_id: /^TestCollection\./})
    

    Next up, ensure there is no database entry in config.databases for “TestCollection”, and if so, remove it through mongos:

    mongos> use config
    switched to db config
    mongos> db.databases.find({_id: "TestCollection"})
    // if any records found, delete them
    mongos> db.databases.remove({_id: "TestCollection"})
    

    Now, ensure there are no entries in config.chunks for any namespaces in the database (like the default test namespace). If there are any, remove through mongos:

    mongos> use config
    switched to db config
    mongos> db.chunks.find({ns: /^test\./})
    // if any records found, delete them
    mongos> db.chunks.remove({ns: /^test\./})
    

    Then, flushRouterConfig on all mongoses:

    mongos> use config
    switched to db config
    mongos> var mongoses = db.mongos.find()
    mongos> while (mongoses.hasNext()) { new Mongo(mongoses.next()._id).getDB("admin").runCommand({flushRouterConfig: 1}) }
    { "flushed" : true, "ok" : 1 }
    ...
    

    Finally, manually connect to each shard primary, and drop the database on the shards (not all shards may have the database, but it’s best to be thorough and issue the dropDatabase() call on all

    Regarding in-progress migrations, you can use this snippet:

    // 2. wait for in-progress migrations to finish, this may take a few seconds
    mongos> while (db.locks.findOne({_id: "balancer", state: {$ne: 0}}) != null) { sleep(1000); }
    

    When done, don’t forget to reenable the balancer:

    mongos> use config
    switched to db config
    
    mongos> db.settings.update({_id: "balancer"}, {$set: {stopped: false}}, true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some databases that have four files each; one for PRIMARY, IDX, IMAGE,
I have a C program that mines a huge data source (20GB of raw
I'm currently working on a project where we have a large data warehouse which
I have been using BinaryFormatter to serialise data to disk but it doesn't seem
I have to process text files 10-20GB in size of the format: field1 field2
I currently have a large .sqlite data store of long string text. It's about
I have this problem: I have a collection of small files that are about
I want to do a bulk load into MongoDB. I have about 200GB of
I have a rails application running on Nginx which needs to serve files for
I have a bash file that contains wget commands to download over 100,000 files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.