[MongoDB] Read preference in a transaction must be primary

MongoDB 4.0.3 ReplicaSet

MongoDB.Driver for .net Core 2.7.3

在Connection String中配置了readPreference=secondaryPreferred:

mongodb://user:password@mongod-1:27017,mongod-2:27017,mongod-3:27017/DBName?connect=replicaSet&readPreference=secondaryPreferred

然后在一个Transaction中读取数据报错:”Read preference in a transaction must be primary”, Transaction中的读取不能使用secondaryPreferred

Leave a Comment