summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/range_deleter_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/range_deleter_service.h')
-rw-r--r--src/mongo/db/s/range_deleter_service.h43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/mongo/db/s/range_deleter_service.h b/src/mongo/db/s/range_deleter_service.h
index 2b8293805e8..2c772053dc6 100644
--- a/src/mongo/db/s/range_deleter_service.h
+++ b/src/mongo/db/s/range_deleter_service.h
@@ -64,6 +64,16 @@ private:
}
}
+ SharedSemiFuture<void> getPendingFuture() {
+ return _pendingPromise.getFuture();
+ }
+
+ void clearPending() {
+ if (!_pendingPromise.getFuture().isReady()) {
+ _pendingPromise.emplaceValue();
+ }
+ }
+
SharedSemiFuture<void> getCompletionFuture() const {
return _completionPromise.getFuture().semi().share();
}
@@ -75,6 +85,8 @@ private:
private:
// Marked ready once the range deletion has been fully processed
SharedPromise<void> _completionPromise;
+
+ SharedPromise<void> _pendingPromise;
};
/*
@@ -98,8 +110,8 @@ private:
*/
class ReadyRangeDeletionsProcessor {
public:
- ReadyRangeDeletionsProcessor(OperationContext* opCtx)
- : _thread(stdx::thread([this] { _runRangeDeletions(); })) {
+ ReadyRangeDeletionsProcessor(OperationContext* opCtx) {
+ _thread = stdx::thread([this] { _runRangeDeletions(); });
stdx::unique_lock<Latch> lock(_mutex);
opCtx->waitForConditionOrInterrupt(
_condVar, lock, [&] { return _threadOpCtxHolder.is_initialized(); });
@@ -149,12 +161,8 @@ private:
*/
void _runRangeDeletions();
- /* Queue containing scheduled range deletions */
- std::queue<RangeDeletionTask> _queue;
- /* Thread consuming the range deletions queue */
- stdx::thread _thread;
- /* Pointer to the (one and only) operation context used by the thread */
- boost::optional<ServiceContext::UniqueOperationContext> _threadOpCtxHolder;
+ Mutex _mutex = MONGO_MAKE_LATCH("ReadyRangeDeletionsProcessor");
+
/*
* Condition variable notified when:
* - The component has been initialized (the operation context has been instantiated)
@@ -163,7 +171,14 @@ private:
*/
stdx::condition_variable _condVar;
- Mutex _mutex = MONGO_MAKE_LATCH("ReadyRangeDeletionsProcessor");
+ /* Queue containing scheduled range deletions */
+ std::queue<RangeDeletionTask> _queue;
+
+ /* Pointer to the (one and only) operation context used by the thread */
+ boost::optional<ServiceContext::UniqueOperationContext> _threadOpCtxHolder;
+
+ /* Thread consuming the range deletions queue */
+ stdx::thread _thread;
};
// Keeping track of per-collection registered range deletion tasks
@@ -203,12 +218,18 @@ public:
* Register a task on the range deleter service.
* Returns a future that will be marked ready once the range deletion will be completed.
*
- * In case of trying to register an already existing task, the future will contain an error.
+ * In case of trying to register an already existing task, the original future will be returned.
+ *
+ * A task can be registered only if the service is up (except for tasks resubmitted on step-up).
+ *
+ * When a task is registered as `pending`, it can be unblocked by calling again the same method
+ * with `pending=false`.
*/
SharedSemiFuture<void> registerTask(
const RangeDeletionTask& rdt,
SemiFuture<void>&& waitForActiveQueriesToComplete = SemiFuture<void>::makeReady(),
- bool fromResubmitOnStepUp = false);
+ bool fromResubmitOnStepUp = false,
+ bool pending = false);
/*
* Deregister a task from the range deleter service.