diff options
author | Tyler Seip <Tyler.Seip@mongodb.com> | 2021-03-10 10:56:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-23 22:34:30 +0000 |
commit | 5fe45689b6eb936190203c66b506d5d042a76eb0 (patch) | |
tree | 4691c2f0e74b383090df2e0c572188554e10a173 /src/mongo/db/service_context.h | |
parent | c4ba167a17edd73665b8a57b94299092f79d47f1 (diff) | |
download | mongo-5fe45689b6eb936190203c66b506d5d042a76eb0.tar.gz |
SERVER-53566: Protect ServiceContext from issuing duplicate operation IDs
Diffstat (limited to 'src/mongo/db/service_context.h')
-rw-r--r-- | src/mongo/db/service_context.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index b93e97e4c2b..57302f199d5 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -37,6 +37,7 @@ #include "mongo/base/global_initializer_registerer.h" #include "mongo/db/logical_session_id.h" +#include "mongo/db/operation_id.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/platform/atomic_word.h" #include "mongo/platform/mutex.h" @@ -124,13 +125,6 @@ private: }; /** - * Every OperationContext is expected to have a unique OperationId within the domain of its - * ServiceContext. Generally speaking, OperationId is used for forming maps of OperationContexts and - * directing metaoperations like killop. - */ -using OperationId = uint32_t; - -/** * Users may provide an OperationKey when sending a command request as a stable token by which to * refer to an operation (and thus an OperationContext). An OperationContext is not required to have * an OperationKey. The presence of an OperationKey implies that the client is either closely @@ -663,6 +657,10 @@ private: std::vector<ClientObserverHolder> _clientObservers; ClientSet _clients; + /** + * Managing classes for our issued operation IDs. + */ + std::shared_ptr<UniqueOperationIdRegistry> _opIdRegistry; stdx::unordered_map<OperationId, Client*> _clientByOperationId; /** @@ -689,9 +687,6 @@ private: // protected by _mutex std::vector<KillOpListenerInterface*> _killOpListeners; - // Counter for assigning operation ids. - AtomicWord<OperationId> _nextOpId{1}; - // When the catalog is restarted, the generation goes up by one each time. AtomicWord<uint64_t> _catalogGeneration{0}; |