MongoDB RS upgrade issue from 4.4 to 5.0

Hi @Rahul_Kanaujia, welcome to the forums :wave:

Please be sure to follow forum posting guidelines relating to code and log samples:

Staring in MongoDB 5.0 values that were previously set using getLastErrorDefaults should now be set using the setDefaultRWConcern command as documented in the 5.0 release notes.

https://mongodb.prakticum-team.ru/docs/manual/release-notes/5.0-compatibility/#removed-customizable-values-for-getlasterrordefaults

Removed Customizable Values For getLastErrorDefaults

Starting in MongoDB 5.0, you cannot specify a default write concern with settings.getLastErrorDefaults other than the default of { w: 1, wtimeout: 0 } . Instead, use the setDefaultRWConcern command to set the default read or write concern configuration for a replica set or sharded cluster.

The replicaset configuration will need to be updated before upgrading the binaries to 5.0.

  • Make sure all the replicaset members are running 4.4 and the cluster is healthy :green_heart:
  • Get the current getLastErrorDefaults : wc=rs.config().settings.getLastErrorDefaults
  • Set the write concern using setDefaultRWConcern command: db.adminCommand({setDefaultRWConcern:1, defaultWriteConcern: wc})
  • Set the getLastErrorDefaults to the value compatible with 5.0 :
    c=rs.config()
    c.settings.getLastErrorDefaults={w:1, wtimeout:0}
    rs.reconfig(c)
    

Proceed with the upgrade to MongoDB 5.0 :white_check_mark: