Skip to content

Commit

Permalink
SERVER-31091 Make Balancer::joinCurrentRound obey the OperationContex…
Browse files Browse the repository at this point in the history
…t deadline

(cherry picked from commit 689e308)
  • Loading branch information
kaloianm committed Oct 18, 2017
1 parent 998863e commit 078f289
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/mongo/db/s/balancer/balancer.cpp
Expand Up @@ -243,8 +243,9 @@ void Balancer::waitForBalancerToStop() {
void Balancer::joinCurrentRound(OperationContext* opCtx) {
stdx::unique_lock<stdx::mutex> scopedLock(_mutex);
const auto numRoundsAtStart = _numBalancerRounds;
_condVar.wait(scopedLock,
[&] { return !_inBalancerRound || _numBalancerRounds != numRoundsAtStart; });
opCtx->waitForConditionOrInterrupt(_condVar, scopedLock, [&] {
return !_inBalancerRound || _numBalancerRounds != numRoundsAtStart;
});
}

Status Balancer::rebalanceSingleChunk(OperationContext* opCtx, const ChunkType& chunk) {
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/s/balancer/balancer.h
Expand Up @@ -110,7 +110,8 @@ class Balancer {

/**
* Potentially blocking method, which will return immediately if the balancer is not running a
* balancer round and will block until the current round completes otherwise.
* balancer round and will block until the current round completes otherwise. If the operation
* context's deadline is exceeded, it will throw an ExceededTimeLimit exception.
*/
void joinCurrentRound(OperationContext* txn);

Expand Down

0 comments on commit 078f289

Please sign in to comment.