Updating to MongoDB 4.4.9

Follow

Countly relies on MongoDB to store and retrieve analytics data.

In a recent update, MongoDB announced the discovery of a bug affecting MongoDB versions 4.4.2 - 4.4.8, which could introduce inconsistencies in the database and thus, lead to data corruption. 

To prevent this bug from happening in the future, even when your instance is not directly impacted, you must upgrade to MongoDB 4.4.9.

Installation Method

This guide explains how to upgrade MongoDB for clients that use online Countly packages.

If you need an offline installation package with all dependencies pre-installed for environments without Internet access, please contact our Support Team by creating a support ticket.

Issue

Due to a bug in the WiredTiger engine, not all data might be committed to the disk. Data in the memory remains correct, thus it is not possible to notice the issue until the MongoDB process is restarted.
Upon restart, if the issue exists, the MongoDB process will not start again and display an Error related to Duplicate Key in the MongoDB Logs.

 

Upgrading to MongoDB 4.4.9

Important note!

If you have a replica set setup, then you can upgrade nodes one by one. But if you have a standalone setup, you should take a snapshot/backup and stop incoming traffic before the upgrade.

To upgrade MongoDB, you need to run these commands on MongoDB Server:

  1. Stop MongoDB process:
    sudo service mongod stop
  2. Uninstall existing MongoDB,
    a. For Ubuntu-based OS:
    sudo apt-get remove -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
    b. For RHEL/Centos-based OS:
    sudo yum erase -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
  3. Install the latest version of MongoDB 4.4,
    a. For Ubuntu-based OS:
    sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install mongodb-org
    b. For RHEL/Centos-based OS:
    sudo yum install -y mongodb-org
  4. Start MongoDB again:
    service mongod restart
  5. Verify MongoDB started and can be connected to:
    mongo
    If the database is not coming up, check the logs:
    tail -f /var/log/mongodb/mongod.log
    If there is an issue of Duplicate Key error, you would need to do an initial resync of data from another node, as explained here.
  6. Repeat for all the nodes/MongoDB servers you have.

 

Was this article helpful?
0 out of 0 found this helpful

Looking for help?