Skip to content

Commit 3b099f6

Browse files
authored
Merge branch 'dev' into af-1730
2 parents 83fa1a5 + c0b4586 commit 3b099f6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/controller/registry-user.controller/registry-user.controller.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ async function updateUser (req, res, next) {
400400
}
401401
}
402402

403-
// UUID of the user will not change, lets get it before we write to avoid read after write issues.
403+
// Move lookups of immutable properties BEFORE the transaction mutation writes to completely bypass read-after-write anomalies
404404
const requestingUserUUID = await userRepo.getUserUUID(req.ctx.user, req.ctx.org, { session })
405-
updatedUserUUID = await userRepo.getUserUUID(req.ctx.user, org.UUID)
405+
updatedUserUUID = await userRepo.getUserUUID(req.ctx.user, org.UUID, { session })
406+
406407
updatedUser = await userRepo.updateUserFull(userToEdit.UUID, body, { session }, true, requestingUserUUID)
407408
await session.commitTransaction()
408409
} catch (error) {
@@ -469,7 +470,8 @@ async function deleteUser (req, res, next) {
469470
}
470471

471472
async function grantRole (req, res, next) {
472-
const session = await mongoose.startSession()
473+
// Explicitly configuring causalConsistency flag for clear DocumentDB context documentation
474+
const session = await mongoose.startSession({ causalConsistency: false })
473475
try {
474476
const orgShortName = req.ctx.params.shortname
475477
const username = req.ctx.params.username
@@ -532,7 +534,8 @@ async function grantRole (req, res, next) {
532534
}
533535

534536
async function revokeRole (req, res, next) {
535-
const session = await mongoose.startSession()
537+
// Explicitly configuring causalConsistency flag for clear DocumentDB context documentation
538+
const session = await mongoose.startSession({ causalConsistency: false })
536539
try {
537540
const orgShortName = req.ctx.params.shortname
538541
const username = req.ctx.params.username

0 commit comments

Comments
 (0)