summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordi Olivares Provencio <jordi.olivares-provencio@mongodb.com>2022-03-31 14:41:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-31 15:56:52 +0000
commite1bac61bcbf8a94689e4a0bf90979d0fcd010c2a (patch)
tree28c40a57603def6d50038048044181257360becd
parentb1cf403753841ab2ea8e7d6bec145e52645d0070 (diff)
downloadmongo-e1bac61bcbf8a94689e4a0bf90979d0fcd010c2a.tar.gz
SERVER-51904 Add feature flag for execution control
-rw-r--r--src/mongo/db/storage/SConscript1
-rw-r--r--src/mongo/db/storage/storage_engine_init.cpp33
-rw-r--r--src/mongo/db/storage/storage_engine_parameters.cpp2
-rw-r--r--src/mongo/db/storage/storage_engine_parameters.idl6
-rw-r--r--src/mongo/util/concurrency/ticketholder.cpp2
-rw-r--r--src/mongo/util/concurrency/ticketholder.h4
6 files changed, 31 insertions, 17 deletions
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index b216260dde0..34f459b894e 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -196,6 +196,7 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/idl/feature_flag',
'$BUILD_DIR/mongo/idl/server_parameter',
],
)
diff --git a/src/mongo/db/storage/storage_engine_init.cpp b/src/mongo/db/storage/storage_engine_init.cpp
index f5749385ac2..7c292ac4c33 100644
--- a/src/mongo/db/storage/storage_engine_init.cpp
+++ b/src/mongo/db/storage/storage_engine_init.cpp
@@ -169,19 +169,26 @@ StorageEngine::LastShutdownState initializeStorageEngine(OperationContext* opCtx
// TODO SERVER-64467: Remove the globalServiceContext for TicketHolders
auto serviceContext = getGlobalServiceContext();
auto& ticketHolders = ticketHoldersDecoration(serviceContext);
- switch (gTicketQueueingPolicy) {
- case QueueingPolicyEnum::Semaphore:
- LOGV2_DEBUG(6382201, 1, "Using Semaphore-based ticketing scheduler");
- ticketHolders.setGlobalThrottling(
- std::make_unique<SemaphoreTicketHolder>(readTransactions),
- std::make_unique<SemaphoreTicketHolder>(writeTransactions));
- break;
- case QueueingPolicyEnum::FifoQueue:
- LOGV2_DEBUG(6382200, 1, "Using FIFO queue-based ticketing scheduler");
- ticketHolders.setGlobalThrottling(
- std::make_unique<FifoTicketHolder>(readTransactions),
- std::make_unique<FifoTicketHolder>(writeTransactions));
- break;
+ if (feature_flags::gFeatureFlagExecutionControl.isEnabledAndIgnoreFCV()) {
+ LOGV2_DEBUG(5190400, 1, "Enabling new ticketing policies");
+ switch (gTicketQueueingPolicy) {
+ case QueueingPolicyEnum::Semaphore:
+ LOGV2_DEBUG(6382201, 1, "Using Semaphore-based ticketing scheduler");
+ ticketHolders.setGlobalThrottling(
+ std::make_unique<SemaphoreTicketHolder>(readTransactions),
+ std::make_unique<SemaphoreTicketHolder>(writeTransactions));
+ break;
+ case QueueingPolicyEnum::FifoQueue:
+ LOGV2_DEBUG(6382200, 1, "Using FIFO queue-based ticketing scheduler");
+ ticketHolders.setGlobalThrottling(
+ std::make_unique<FifoTicketHolder>(readTransactions),
+ std::make_unique<FifoTicketHolder>(writeTransactions));
+ break;
+ }
+ } else {
+ ticketHolders.setGlobalThrottling(
+ std::make_unique<SemaphoreTicketHolder>(readTransactions),
+ std::make_unique<SemaphoreTicketHolder>(writeTransactions));
}
}
diff --git a/src/mongo/db/storage/storage_engine_parameters.cpp b/src/mongo/db/storage/storage_engine_parameters.cpp
index 729bc99ecb1..5a7a44463f8 100644
--- a/src/mongo/db/storage/storage_engine_parameters.cpp
+++ b/src/mongo/db/storage/storage_engine_parameters.cpp
@@ -33,7 +33,7 @@
namespace mongo {
-QueueingPolicyEnum gTicketQueueingPolicy{QueueingPolicyEnum::Semaphore};
+QueueingPolicyEnum gTicketQueueingPolicy{QueueingPolicyEnum::FifoQueue};
void TicketQueueingPolicy::append(OperationContext*,
BSONObjBuilder& builder,
diff --git a/src/mongo/db/storage/storage_engine_parameters.idl b/src/mongo/db/storage/storage_engine_parameters.idl
index 03139a1e8bc..dcd72e5d6db 100644
--- a/src/mongo/db/storage/storage_engine_parameters.idl
+++ b/src/mongo/db/storage/storage_engine_parameters.idl
@@ -67,6 +67,12 @@ server_parameters:
validator:
gt: 0
+feature_flags:
+ featureFlagEnableExecutionControl:
+ description: Enables the new execution control queueing policy
+ cpp_varname: feature_flags::gFeatureFlagExecutionControl
+ default: false
+
enums:
QueueingPolicy:
description: Queueing policy to use for obtaining tickets
diff --git a/src/mongo/util/concurrency/ticketholder.cpp b/src/mongo/util/concurrency/ticketholder.cpp
index 4043eea04b7..599c9c744e4 100644
--- a/src/mongo/util/concurrency/ticketholder.cpp
+++ b/src/mongo/util/concurrency/ticketholder.cpp
@@ -286,7 +286,7 @@ void FifoTicketHolder::release() {
// a waiting operation to avoid leaving an operation waiting indefinitely.
while (true) {
if (!_queue.empty()) {
- auto& elem = _queue.front();
+ auto elem = _queue.front();
_enqueuedElements.subtractAndFetch(1);
{
stdx::lock_guard elemLk(elem->modificationMutex);
diff --git a/src/mongo/util/concurrency/ticketholder.h b/src/mongo/util/concurrency/ticketholder.h
index 9516aa92dc7..6ea01831b87 100644
--- a/src/mongo/util/concurrency/ticketholder.h
+++ b/src/mongo/util/concurrency/ticketholder.h
@@ -157,7 +157,7 @@ private:
void _release(WithLock);
Mutex _resizeMutex =
- MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "FifoTicketHolder::_resizeMutex");
+ MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(2), "FifoTicketHolder::_resizeMutex");
AtomicWord<int> _capacity;
enum class WaitingState { Waiting, Cancelled, Assigned };
struct WaitingElement {
@@ -170,7 +170,7 @@ private:
// _queueMutex protects all modifications made to either the _queue, or the statistics of the
// queue.
Mutex _queueMutex =
- MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "FifoTicketHolder::_queueMutex");
+ MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), "FifoTicketHolder::_queueMutex");
AtomicWord<int> _enqueuedElements;
AtomicWord<int> _ticketsAvailable;
};