Question

MongoDB updated this morning to 7.0.1, now wont restart

We have a pod running a MongoDB instance. It was automatically upgraded this morning to 7.0.1 and now wont restart citing;

initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCo │
│ mpatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"5.0\" }. See https://docs.mongodb.com/master/release-notes/6.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value '5. │
│ 0'; expected '6.0' or '6.3' or '7.0'

Where would I update this Compatibility version? The pod isn’t running at this point.

Or can I fix the version of MongoDB on the pod to a prior version.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi there,

Based on the output that you’ve shared it seems that MongoDB was upgraded to a newer version without the featureCompatibilityVersion being upgraded in stages.

When upgrading MongoDB across multiple major versions, it’s recommended to upgrade one major version at a time and update the featureCompatibilityVersion in between.

Here’s what you can do to recover:

Always make sure to backup your data before performing any upgrade operations.

1. Downgrade MongoDB:

First, downgrade your MongoDB to the previous stable version you were using (e.g., 5.0).

As you mentioned that it is a MongoDB pod, I would assume that you are using Kubernetes, you can change the image version in your MongoDB deployment configuration.

For instance:

spec:
  containers:
  - name: mongodb
    image: mongo:5.0

After making the change, apply the updated configuration:

kubectl apply -f your-deployment-file.yaml

Once the pod is running with the downgraded version, verify that you can connect to your MongoDB instance.

2. Set the featureCompatibilityVersion:

Connect to your MongoDB instance and set the featureCompatibilityVersion:

mongo
db.adminCommand({ setFeatureCompatibilityVersion: "5.0" });

3. Upgrade Step-by-step:

Now, when you’re ready to upgrade:

  1. Upgrade to MongoDB 6.0 and update featureCompatibilityVersion to “6.0”.
  2. Then, if needed, upgrade to MongoDB 6.3 and update featureCompatibilityVersion to “6.3”.
  3. Finally, upgrade to MongoDB 7.0 and set featureCompatibilityVersion to “7.0”.

Always make sure to backup your data before performing any upgrade operations.

Preventing Automatic Upgrades:

To prevent unexpected upgrades in the future, always pin your MongoDB version in your Kubernetes configurations (or whatever method you use to deploy). For instance, instead of using mongo:latest as your image, use mongo:5.0 or whatever specific version you intend to use.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel