Home > OS >  MongoDB Majority Read Concern
MongoDB Majority Read Concern

Time:10-19

I am working on mongoDB version 4.2

I need to cahnge the read concern from majority to local.

Accroding to the documentation the only way to do that for this version and lower versions is to change the configuration file by setting replication.enableMajorityReadConcern to false.

However, I did not find any indication on how to do that. Tried:

replication:
  replSetName: rs0
  replication.enableMajorityReadConcern: false

and

replication:
  replSetName: rs0
  replication.enableMajorityReadConcern = false

but both fails.

What is the correct way to do this then?

CodePudding user response:

Try

replication:
  replSetName: rs0
  enableMajorityReadConcern: false

Note, this parameter has been removed in MongoDB version 5.0. see enableMajorityReadConcern Is Not Configurable

The long-term solution might be Mitigate Performance Issues with PSA Replica Set

CodePudding user response:

You can supply a value in your connection string. For example:

mongodb://db0.example.com,db1.example.com,db2.example.com/?replicaSet=myRepl&readConcernLevel=local

See https://docs.mongodb.com/manual/reference/connection-string/ and look for readConcern Options

GLobal Settings

If you are seeking global settings, see setDefaultRWConcern at:

https://docs.mongodb.com/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern

  • Related