8

Is there a way to regenerate a missing WiredTiger.wt? Our MongoDB instance stopped working (bizarrely), and that file got missing from the dbpath folder—Seems like this behaviour is known.

BTW, the repair utility doesn't succeed:

file:WiredTiger.wt, connection: .//WiredTiger.wt: handle-open: open: No such file or directory

Losing the database is hard to stomach...

Any idea? Thanks.

P.S. We still got all the other .wt files.

aspretto
  • 117
  • 3
  • 9
  • Do you have an older backup of your `dbPath` or is this the only copy of your data? The `WiredTiger.wt` file includes essential metadata and cannot be recreated. What specific version of MongoDB are you using? – Stennie Nov 30 '16 at 21:25
  • That's the whole issue, we don't have any backup, since the project is brand new... We didn't bother, but, you live and learn, huh? :) (v3.2.10) – aspretto Nov 30 '16 at 21:46
  • Very unfortunate lesson, but hopefully new project means you haven't lost too much data. If you are desperate it might be possible (but painful) to dump some data from the collections using WiredTiger command line tools, but that's heading down a heroic and unsupported path. For production environments with critical data I would recommend using a continuous backup service (eg. MongoDB Cloud Manager) and deploying as a replica set. – Stennie Nov 30 '16 at 22:00
  • Are you able to share any details or logs with context on the "stopped working" incident? Did you shut down `mongod`, did it shutdown itself, ... ? Also, how have you deployed MongoDB (directly, in Docker/container/...) and on what O/S? – Stennie Nov 30 '16 at 22:06
  • @Stennie Sure, anything you want–We're running MongoDB on a 16.10 Ubuntu. The database is used by a NodeBB instance, and there's no Docker–or any deployment automation system–involved. We simply installed MongoDB from the a release package. I'll try to get you some logs (will edit the original post). Thank you for your time. – aspretto Dec 01 '16 at 12:47

1 Answers1

4

The WiredTiger.wt file includes essential metadata about a MongoDB data directory: which collections & indexes exist as well as the latest checkpoints in each of those files. If WiredTiger.wt has been completely removed from your dbPath there is currently no process or tool to recreate this metadata, short of restoring the full dbPath from a backup copy. While you do have data files, you've unfortunately lost the catalog describing what these files contain and how they relate.

Stennie
  • 63,885
  • 14
  • 149
  • 175
  • 1
    I experienced this issue in local (another time I lost the db because another error, after a clean shotdown).I'm very worried about going on production with those issue. If I knew it before I would totally drop mongodb for postgres or even mysql. – alfredopacino Nov 30 '16 at 22:00
  • @alfredopacino Removal of data files is not an expected (or common) issue, but irrespective of your database you should always have a backup strategy for essential data. Without context on the MongoDB errors you encountered, it's hard to know if there might be steps you can take to improve your deployment or admin practices (and unrelated to the question here which is "Can I recreate a missing WiredTiger.wt file?"). Use of some deployment approaches (eg. Docker) or filesystems (NFS) can be more problematic in terms of performance or potential file corruption. – Stennie Nov 30 '16 at 22:17
  • It is worth reviewing the [Production Notes](https://docs.mongodb.com/manual/administration/production-notes/) for suggested settings that might apply, but for more involved discussion on your MongoDB deployment (rather than a specific question) I would suggest posting on the [mongodb-user group](https://groups.google.com/forum/#!forum/mongodb-user). – Stennie Dec 01 '16 at 00:21
  • @alfredopacino Thanks for the Jira link. There's not really enough information to understand what happened with your deployment, but an obvious red flag is "I operated on the db directory c:\myproject\data through git)". If your `dbPath` is being manipulated by external tools such as `git` (or Dropbox, etc) while the database server is running (or you checkout different versions of data files from git), it is easy to accidentally introduce inconsistencies. Typically you also do not want to commit large binaries / data files into version control as that will bloat your repo quickly. – Stennie Dec 01 '16 at 11:02