Backport 1.7.x: Add ability to customize some timeouts in MongoDB database plugin #11637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport to 1.7.x: #11600
This PR adds the ability to customize
SocketTimeout
,ConnectTimeout
, andServerSelectionTimeout
within MongoDB connections. Vault passes these values to the MongoDB library when it makes a client connection.This also makes some improvements around throughput. Previously, when an operation came to the plugin (creating/destroying a user, etc.), it would lock a mutex for the entirety of the operation. This resulted in the plugin forcing all requests to be single-threaded. This moves the mutex lock a bit lower in the plugin to try to limit its scope and allow multiple threads to be manipulating users at the same time. I did run a bunch of tests to try to produce races and didn't find any within the plugin code. However, I did find a race within the DB engine which I think is fixed in
builtin/logical/database/path_rotate_credentials.go
. The lock was being unlocked before the connection was being being closed & removed from the DBI map (b.connections
). This probably wasn't a serious issue in practice as the map isn't changed in this manner very frequently.