Difference between getLastErrorDefaults and defaultReadConcern/defaultWriteConcern

there is a parameter getLastErrorDefaults in rs.conf() which can set rw concern.
and there is another two parameters defaultReadConcern/defaultWriteConcern can be setted using admincommand setdefaultrwconcern which control the global rw concern.

what is the difference between getLastErrorDefaults and defaultReadConcern/defaultWriteConcern?
for example ,three node replication set ,it i set getLastErrorDefaults w:1 in rs.conf(), and set defaultWriteConcern w:majority, then when client inserts one document, which writeconcern does it use?

Hi @Yi_deng ,

Since MongoDB 5.0 getLastErrorDefaults cannot be customised and has been replaced by using setDefaultRWConcern[1].

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 defaultWriteConcern will take precedence over getLastErrorDefaults.


o ,got it,thanks a lot.