Skip to content

Commit 650a680

Browse files
committed
testing read preference at transaction level
1 parent 57353ba commit 650a680

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/controller/registry-org.controller/registry-org.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async function getOrg (req, res, next) {
134134
*/
135135
async function createOrg (req, res, next) {
136136
try {
137-
const session = await mongoose.startSession({ causalConsistency: false })
137+
const session = await mongoose.startSession({ causalConsistency: false, readPreference: 'primary' })
138138
const repo = req.ctx.repositories.getBaseOrgRepository()
139139
const body = req.ctx.body
140140
const isSecretariat = await repo.isSecretariatByShortName(req.ctx.org, { session })

src/utils/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getMongoConnectionString () {
2626
logger.info(`Will try to connect to database ${dbName} at ${dbHost}:${dbPort}`)
2727

2828
if (process.env.useAWS) {
29-
return `mongodb://${dbLoginPrepend}${dbHost}:${dbPort}/${dbName}?retryWrites=false`
29+
return `mongodb://${dbLoginPrepend}${dbHost}:${dbPort}/${dbName}?replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false`
3030
} else {
3131
return `mongodb://${dbLoginPrepend}${dbHost}:${dbPort}/${dbName}`
3232
}

0 commit comments

Comments
 (0)