Is there anyway to recover data in collection-*.wt and index-*.wt without the WiredTiger.wt metafile?

Is there anyway to recover data in collection-.wt and index-.wt without the WiredTiger.wt metafile?

I am running into a corrupt WiredTiger.wt file:

2021-04-04T23:09:43.541+0000 E STORAGE [initandlisten] WiredTiger (-31802) [1617577783:541456][18206:0x7fb27b94cdc0], file:WiredTiger.wt, connection: WiredTiger.wt: handle-read: pread: failed to read 4096 bytes at offset 73728: WT_ERROR: non-specific WiredTiger error

Any thoughts?

1 Like

Welcome to the MongoDB Community @William_Crowell1!

What specific version of MongoDB server are you running?

Salvaging data from corrupted files is challenging, but your general options are as described in Recover corrupted files (MongoDB 3.0.12) .wt.

Regards,
Stennie

Hi Stennie,
I am running Mongo 3.2.7.
Thanks,
Bill Crowell

Hi @William_Crowell1,

Please have a below link if that will help in your case.

Rohit and Stennie,

Thanks for the link. I have read through this and tried the steps in the article. The issue is that you need a non-corrupt WiredTiger.wt file to use the wt commands in that article.

How we resolved it is a bit of a hack, but here is what we did. We created a new and empty MongoDB 4.0.5 instance. Then, we created a new collection in this new instance for each of the collections in the old instance. The collection names do not have to be the same, but the collection-.wt filenames must be static on the new instance. These collection-.wt file names cannot be predetermined and cannot change. We had about 42 collections in our old instance, therefore, we created 42 new collections on the 4.0.5 instance. Next, we inserted an arbitrary string (document) into these new collections. They cannot be empty collections because the repair step will not work. We then copied over the old collection*-.wt files while again keeping the new collection file names. Next, we started the MongoDB 4.0.5 instance with the --repair option. This added the metadata to the WiredTiger.wt file. The challenge is mapping the collection names from the old instance over to the new instance, but we at least have the data. Lastly, we ran a script to recreate the indexes on the collections.

Again, a hack but it worked.

Regards,

Bill Crowell

1 Like

The engineer who resolved this issue wrote the following article on Medium on how it was resolved: https://medium.com/@imunscarred/repairing-mongodb-when-wiredtiger-wt-file-is-corrupted-9405978751b5

1 Like