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 "
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.
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
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 :