3

Is there any way to upgrade a mongo database after the mongodb package was unintentionally upgraded (3.4.9 -> 3.6.1)?

According to the mongo docs, as a prerequisite of the upgrade, featureCompatibilityVersion has to be set from the mongo cli tool, which, however, needs a running mongod database daemon, which, however, won't run if mongodb package was already upgraded and the database was not set the featureCompatibilityVersion flag.

I'm on ArchLinux, I had mongodb in IgnorePkg but it's dependencies boost-libs and wiredtiger got upgraded anyways. Having pacman cache already wiped out, I compiled older versions of the packages myself, but running mongodb keeps failing with this error:

unsupported WiredTiger file version: this build  only supports major/minor versions up to 1/0,  and the file is version 2/0: WT_ERROR: non-specific WiredTiger error

I don't have a clue what the hell this means (the problematic version of wiredtiger is 2.9.3-1, version after the upgrade is 2.9.3.20171205-2).

Seems like I can neither downgrade nor upgrade...

Other cli tools (e.g. mongodump) also won't run without a running database, is there any other possibility (some wiredtiger related tool)? Deleting the database and starting afresh is not an option.

Tomas Varga
  • 1,432
  • 15
  • 23

3 Answers3

4

I solved the problem by installing the older version of mongodb on a system for which it wasn't a problem to get it pre-packaged (well, Windows 10, even though oficially it's stated the package is for Windows Server 2008), copying the database files (contents of /var/lib/mongodb) there, running it with --dbpath param (mongod --dbpath /path/to/dbfiles), setting the compatibility flag according to the docs and finally copying the db files back to the server.

Would like to know about a better option, but it's good to know the db files are easily transferable to another system, even another architecture (the db was relatively simple and small though).

Tomas Varga
  • 1,432
  • 15
  • 23
  • I'm facing the same issue. I can't believe how stupid this situation is, but I appreciate your solution. Going to give this a shot and see if it works. Ugh. – aikorei Nov 02 '18 at 20:42
  • Could you explain a little bit. I run into the same probleme, but this solution did not work for me. Had a Mongo 3.4 and upgraded it (without paying attention) to 3.6 without flag. So actually Mongo 3.6 could not start becaus no flag was set. And 3.4 could not start because the db-files are in 3.6 format... I tried to get another Mongo 3.4 installation, put the files inside and launch "mongo --dbpath " but it still do not work this the smae error ( WiredTiger error (-31802)...) – Paul Zakharov Nov 13 '19 at 13:59
  • Anyone who runs by this, you should also try this if you can't start mongo after moving the db files to another server: *mongo --dbpath --repair* – blizz Nov 05 '20 at 22:10
  • In case someone is experiencing this issue on 2023: Installing MongoDB 4.0 or newer is not as easy as it was since those version are not published anymore in the most popular package managers. I had to go a different route and posted the step by step here: https://stackoverflow.com/a/75197531/1819588 Hope this save some people time. – Davo Jan 22 '23 at 00:32
1

Running mongod --repair worked for me.

-1

here similar issue, unintentionally upgrade from 4.2.1 to 4.4.3, then mongodb can NOT started..

Final worked solution:

  1. uninstall (latest, but not worked version: 4.4.3)

brew uninstall mongodb-community

  1. reinstall, old but worked 4.2.1

brew install mongodb-community@4.2

  1. run
  • for now: brew services run mongodb-community@4.2
  • for now and set bootable: brew services start mongodb-community@4.2
  1. check status

brew services

crifan
  • 12,947
  • 1
  • 71
  • 56