MongoDB RS upgrade issue from 4.4 to 5.0

Hi,

I am facing issue while upgrading MongoDB server of RS member from 4.4 to 5.0 due to RW concern issue.

Getting below error while starting MongoDB server with 5.0 binary.

“ctx”:“ReplCoord-0”,“msg”:“Fatal assertion”,“attr”:{“msgid”:5624100,“error”:“IllegalOperation: Failed to start up: Replica set config contains customized getLastErrorDefaults, which has been deprecated and is now ignored. Use setDefaultRWConcern instead to set a cluster-wide default writeConcern.”,“file”:“src/mongo/db/repl/repl_set_config_checks.cpp”,“line”:444 "

I am using community edition of MongoDB server.

Thanks in advance.

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://www.mongodb.com/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:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.