mongodbwiredtiger

Can I delete old ".collection" files from mongodb folder without loosing data?


I found the following two WiredTiger files in my mongodb folder and was wondering if I can delete them. I couldn't find any information on these "dot" files. As none of my collections have nearly their sizes I assume they are old files from an update/upgrade or database crash.

-rw-------  1 mongodb mongodb  37G Aug  1  2020 .collection-2-2197222002666000012.wt.gl1vVk
-rw-------  1 mongodb mongodb  30G Aug  1  2020 .collection-24--3282032164058503930.wt.ar232G

And the following files do exist (not "dot" files and/or with same number or "id")

-rw-------  1 mongodb mongodb 371G Jan 26 10:33 collection-2-2197222002666000012.wt
-rw-------  1 mongodb mongodb 8.4G Jan 26 10:33 collection-10-2197222002666000012.wt
-rw-------  1 mongodb mongodb  18M Jan 26 10:28 collection-21-2197222002666000012.wt
-rw-------  1 mongodb mongodb 140K Jan 26 10:33 collection-28-2197222002666000012.wt
-rw-------  1 mongodb mongodb 496K Jan 22 15:15 collection-31-2197222002666000012.wt
-rw-------  1 mongodb mongodb  60K Jan 26 10:33 collection-33-2197222002666000012.wt
-rw-------  1 mongodb mongodb  36K Jan 26 00:31 collection-36-2197222002666000012.wt

-rw-------  1 mongodb mongodb 2.5G Jan 26 10:31 collection-2--2646629207231057360.wt
-rw-------  1 mongodb mongodb 913M Jan  8 06:59 collection-2--3119428849725479179.wt
-rw-------  1 mongodb mongodb  13G Jan 26 10:40 collection-2--7079456230197184981.wt
-rw-------  1 mongodb mongodb  44K May 15  2021 collection-2--7434527923482181360.wt
-rw-------  1 mongodb mongodb 371G Jan 26 10:40 collection-2-2197222002666000012.wt
-rw-------  1 mongodb mongodb 171M Jan 26 10:24 collection-2-2875991018046119712.wt
-rw-------  1 mongodb mongodb  84K Jan 23 18:26 collection-2-4767559832689929150.wt

I'm running mongodb version "4.4.12" on ubuntu and started with 3.6 or something.


Solution

  • Deleting files in wiredTiger storage engine data folder is very risky operation , I would sugest you add SECONDARY member and init sync it , then switch it to PRIMARY and then you can delete the entire folder and init sync the old member , if the mentioned files disappear then you are fine ...