MongoDB - Fix write_concern param (#18546)

* fix writeconcern defaulting to majority

* add changelog

* restart CI tests

* fix tests

* add package
This commit is contained in:
Milena Zlaticanin 2022-12-23 17:14:41 -06:00 committed by GitHub
parent bee137334d
commit d9b8fb6877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

3
changelog/18546.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
database/mongodb: Fix writeConcern set to be applied to any query made on the database
```

View File

@ -210,9 +210,19 @@ func (m *MongoDB) DeleteUser(ctx context.Context, req dbplugin.DeleteUserRequest
db = "admin" db = "admin"
} }
// Set the write concern. The default is majority.
writeConcern := writeconcern.New(writeconcern.WMajority())
opts, err := m.getWriteConcern()
if err != nil {
return dbplugin.DeleteUserResponse{}, err
}
if opts != nil {
writeConcern = opts.WriteConcern
}
dropUserCmd := &dropUserCommand{ dropUserCmd := &dropUserCommand{
Username: req.Username, Username: req.Username,
WriteConcern: writeconcern.New(writeconcern.WMajority()), WriteConcern: writeConcern,
} }
err = m.runCommandWithRetry(ctx, db, dropUserCmd) err = m.runCommandWithRetry(ctx, db, dropUserCmd)