diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2019-01-04 12:19:37 -0500 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2019-01-07 12:08:23 -0500 |
commit | 11bb071e91461b1f8e40b9b15ddf3b9e1a2d23d1 (patch) | |
tree | 7037865f9bf4445fb3295ca7ce72f4182f012554 /src/mongo/db | |
parent | 6a0a21214dd96663c899cb8f2562d6121351ed3c (diff) | |
download | mongo-11bb071e91461b1f8e40b9b15ddf3b9e1a2d23d1.tar.gz |
SERVER-36644 remove AtomicWord typedefs
Diffstat (limited to 'src/mongo/db')
69 files changed, 187 insertions, 186 deletions
diff --git a/src/mongo/db/auth/authorization_manager_impl.h b/src/mongo/db/auth/authorization_manager_impl.h index a734a1301b8..c3e68183c25 100644 --- a/src/mongo/db/auth/authorization_manager_impl.h +++ b/src/mongo/db/auth/authorization_manager_impl.h @@ -203,7 +203,7 @@ private: /** * A cache of whether there are any users set up for the cluster. */ - AtomicBool _privilegeDocsExist; + AtomicWord<bool> _privilegeDocsExist; std::unique_ptr<AuthzManagerExternalState> _externalState; @@ -256,7 +256,7 @@ private: */ stdx::condition_variable _fetchPhaseIsReady; - AtomicBool _inUserManagementCommand{false}; + AtomicWord<bool> _inUserManagementCommand{false}; }; extern int authorizationManagerCacheSize; diff --git a/src/mongo/db/auth/sasl_options.cpp b/src/mongo/db/auth/sasl_options.cpp index 8a8597304b3..ab6152d7556 100644 --- a/src/mongo/db/auth/sasl_options.cpp +++ b/src/mongo/db/auth/sasl_options.cpp @@ -210,7 +210,7 @@ ExportedServerParameter<std::string, ServerParameterType::kStartupOnly> SASLAuth class ExportedScramIterationCountParameter : public ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime> { public: - ExportedScramIterationCountParameter(StringData name, AtomicInt32* value, int minimum) + ExportedScramIterationCountParameter(StringData name, AtomicWord<int>* value, int minimum) : ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>( ServerParameterSet::getGlobal(), name.toString(), value), _minimum(minimum) {} diff --git a/src/mongo/db/auth/sasl_options.h b/src/mongo/db/auth/sasl_options.h index c88da92b615..b9df88e04cf 100644 --- a/src/mongo/db/auth/sasl_options.h +++ b/src/mongo/db/auth/sasl_options.h @@ -51,9 +51,9 @@ struct SASLGlobalParams { std::string hostName; std::string serviceName; std::string authdPath; - AtomicInt32 scramSHA1IterationCount; - AtomicInt32 scramSHA256IterationCount; - AtomicInt32 authFailedDelay; + AtomicWord<int> scramSHA1IterationCount; + AtomicWord<int> scramSHA256IterationCount; + AtomicWord<int> authFailedDelay; SASLGlobalParams(); }; diff --git a/src/mongo/db/auth/user.h b/src/mongo/db/auth/user.h index c77b3e551df..c96a03ed5c4 100644 --- a/src/mongo/db/auth/user.h +++ b/src/mongo/db/auth/user.h @@ -252,7 +252,7 @@ private: RestrictionDocuments _restrictions; // Indicates whether the user has been marked as invalid by the AuthorizationManager. - AtomicBool _isValid{true}; + AtomicWord<bool> _isValid{true}; }; using UserHandle = std::shared_ptr<User>; diff --git a/src/mongo/db/auth/user_cache_invalidator_job_parameters.idl b/src/mongo/db/auth/user_cache_invalidator_job_parameters.idl index 3f662facedb..19a37d19d5f 100644 --- a/src/mongo/db/auth/user_cache_invalidator_job_parameters.idl +++ b/src/mongo/db/auth/user_cache_invalidator_job_parameters.idl @@ -40,7 +40,7 @@ server_parameters: checks to determine whether the in-memory cache of user objects has stale data, and if so, clears the cache. If there are no changes to user objects, mongos will not clear the cache. cpp_varname: userCacheInvalidationIntervalSecs - cpp_vartype: AtomicInt32 + cpp_vartype: AtomicWord<int> set_at: - startup - runtime diff --git a/src/mongo/db/catalog/multi_index_block.idl b/src/mongo/db/catalog/multi_index_block.idl index 14c5e3bf696..3d1d4a145d7 100644 --- a/src/mongo/db/catalog/multi_index_block.idl +++ b/src/mongo/db/catalog/multi_index_block.idl @@ -39,7 +39,7 @@ server_parameters: - runtime - startup cpp_varname: useReadOnceCursorsForIndexBuilds - cpp_vartype: AtomicBool + cpp_vartype: AtomicWord<bool> default: true maxIndexBuildMemoryUsageMegabytes: @@ -48,7 +48,7 @@ server_parameters: - runtime - startup cpp_varname: maxIndexBuildMemoryUsageMegabytes - cpp_vartype: AtomicInt32 + cpp_vartype: AtomicWord<int> default: 500 validator: gte: 100 diff --git a/src/mongo/db/catalog/util/partitioned_test.cpp b/src/mongo/db/catalog/util/partitioned_test.cpp index f7eb220f37c..1bffbf7c201 100644 --- a/src/mongo/db/catalog/util/partitioned_test.cpp +++ b/src/mongo/db/catalog/util/partitioned_test.cpp @@ -235,7 +235,7 @@ TEST(PartitionedConcurrency, ShouldProtectConcurrentAccesses) { std::vector<stdx::thread> threads; const size_t opsPerThread = 1000; - AtomicUInt32 ready{0}; + AtomicWord<unsigned> ready{0}; for (size_t threadId = 1; threadId <= numThreads; ++threadId) { auto workerThreadBody = [&, threadId, opsPerThread]() { diff --git a/src/mongo/db/collection_index_usage_tracker.h b/src/mongo/db/collection_index_usage_tracker.h index c5d15769f5f..6a784ec8bd7 100644 --- a/src/mongo/db/collection_index_usage_tracker.h +++ b/src/mongo/db/collection_index_usage_tracker.h @@ -70,7 +70,7 @@ public: } // Number of operations that have used this index. - AtomicInt64 accesses; + AtomicWord<long long> accesses; // Date/Time that we started tracking index usage. Date_t trackerStartTime; diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index a5008110e29..23c7261d18d 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -165,7 +165,7 @@ void assertCollectionNotNull(const NamespaceString& nss, AutoT& autoT) { } // namespace -AtomicUInt32 Config::JOB_NUMBER; +AtomicWord<unsigned> Config::JOB_NUMBER; JSFunction::JSFunction(const std::string& type, const BSONElement& e) { _type = type; diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h index 20c5bec2173..13fd4a43cd6 100644 --- a/src/mongo/db/commands/mr.h +++ b/src/mongo/db/commands/mr.h @@ -250,7 +250,7 @@ public: // if the output collection is sharded, we must be told what UUID to use for it boost::optional<UUID> finalOutputCollUUID; - static AtomicUInt32 JOB_NUMBER; + static AtomicWord<unsigned> JOB_NUMBER; }; // end MRsetup /** diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp index b3604fe8f55..8723904ba81 100644 --- a/src/mongo/db/concurrency/d_concurrency_test.cpp +++ b/src/mongo/db/concurrency/d_concurrency_test.cpp @@ -188,7 +188,7 @@ TEST_F(DConcurrencyTestFixture, ResourceMutex) { void waitFor(int n) { waitFor([this, n]() { return this->step.load() == n; }); } - AtomicInt32 step{0}; + AtomicWord<int> step{0}; } state; stdx::thread t1([&]() { @@ -1127,7 +1127,7 @@ TEST_F(DConcurrencyTestFixture, Stress) { std::vector<std::pair<ServiceContext::UniqueClient, ServiceContext::UniqueOperationContext>> clients = makeKClientsWithLockers(kMaxStressThreads); - AtomicInt32 ready{0}; + AtomicWord<int> ready{0}; std::vector<stdx::thread> threads; @@ -1251,7 +1251,7 @@ TEST_F(DConcurrencyTestFixture, StressPartitioned) { std::vector<std::pair<ServiceContext::UniqueClient, ServiceContext::UniqueOperationContext>> clients = makeKClientsWithLockers(kMaxStressThreads); - AtomicInt32 ready{0}; + AtomicWord<int> ready{0}; std::vector<stdx::thread> threads; for (int threadId = 0; threadId < kMaxStressThreads; threadId++) { @@ -1753,8 +1753,8 @@ TEST_F(DConcurrencyTestFixture, CompatibleFirstWithXSXIXIS) { TEST_F(DConcurrencyTestFixture, CompatibleFirstStress) { int numThreads = 8; int testMicros = 500'000; - AtomicUInt64 readOnlyInterval{0}; - AtomicBool done{false}; + AtomicWord<unsigned long long> readOnlyInterval{0}; + AtomicWord<bool> done{false}; std::vector<uint64_t> acquisitionCount(numThreads); std::vector<uint64_t> timeoutCount(numThreads); std::vector<uint64_t> busyWaitCount(numThreads); diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 8b3c8cf7abc..8ffbee8c523 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -112,7 +112,7 @@ const ResourceId resourceIdGlobal = ResourceId(RESOURCE_GLOBAL, ResourceId::SING const Milliseconds MaxWaitTime = Milliseconds(500); // Dispenses unique LockerId identifiers -AtomicUInt64 idCounter(0); +AtomicWord<unsigned long long> idCounter(0); // Partitioned global lock statistics, so we don't hit the same bucket PartitionedInstanceWideLockStats globalStats; diff --git a/src/mongo/db/concurrency/lock_stats.cpp b/src/mongo/db/concurrency/lock_stats.cpp index b4e1105c081..8a3410fc6ef 100644 --- a/src/mongo/db/concurrency/lock_stats.cpp +++ b/src/mongo/db/concurrency/lock_stats.cpp @@ -131,8 +131,8 @@ void LockStats<CounterType>::reset() { } -// Ensures that there are instances compiled for LockStats for AtomicInt64 and int64_t +// Ensures that there are instances compiled for LockStats for AtomicWord<long long> and int64_t template class LockStats<int64_t>; -template class LockStats<AtomicInt64>; +template class LockStats<AtomicWord<long long>>; } // namespace mongo diff --git a/src/mongo/db/concurrency/lock_stats.h b/src/mongo/db/concurrency/lock_stats.h index 6add6cfefa6..188b92565d2 100644 --- a/src/mongo/db/concurrency/lock_stats.h +++ b/src/mongo/db/concurrency/lock_stats.h @@ -46,7 +46,7 @@ struct CounterOps { return counter; } - static int64_t get(const AtomicInt64& counter) { + static int64_t get(const AtomicWord<long long>& counter) { return counter.load(); } @@ -54,7 +54,7 @@ struct CounterOps { counter = value; } - static void set(AtomicInt64& counter, int64_t value) { + static void set(AtomicWord<long long>& counter, int64_t value) { counter.store(value); } @@ -62,11 +62,11 @@ struct CounterOps { counter += value; } - static void add(int64_t& counter, const AtomicInt64& value) { + static void add(int64_t& counter, const AtomicWord<long long>& value) { counter += value.load(); } - static void add(AtomicInt64& counter, int64_t value) { + static void add(AtomicWord<long long>& counter, int64_t value) { counter.addAndFetch(value); } }; @@ -208,7 +208,7 @@ private: }; typedef LockStats<int64_t> SingleThreadedLockStats; -typedef LockStats<AtomicInt64> AtomicLockStats; +typedef LockStats<AtomicWord<long long>> AtomicLockStats; /** diff --git a/src/mongo/db/concurrency/write_conflict_exception.cpp b/src/mongo/db/concurrency/write_conflict_exception.cpp index 7be5003291f..3885f6491f5 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.cpp +++ b/src/mongo/db/concurrency/write_conflict_exception.cpp @@ -40,7 +40,7 @@ namespace mongo { -AtomicBool WriteConflictException::trace(false); +AtomicWord<bool> WriteConflictException::trace(false); WriteConflictException::WriteConflictException() : DBException(Status(ErrorCodes::WriteConflict, "WriteConflict")) { diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index 9e8c4c4fcbf..e0844cb7ae7 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -61,7 +61,7 @@ public: * If true, will call printStackTrace on every WriteConflictException created. * Can be set via setParameter named traceWriteConflictExceptions. */ - static AtomicBool trace; + static AtomicWord<bool> trace; private: void defineOnlyInFinalSubclassToPreventSlicing() final {} diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp index e6e3ad70b28..bb1b7ff410d 100644 --- a/src/mongo/db/free_mon/free_mon_controller_test.cpp +++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp @@ -364,8 +364,8 @@ public: private: - AtomicInt32 _registers; - AtomicInt32 _metrics; + AtomicWord<int> _registers; + AtomicWord<int> _metrics; executor::ThreadPoolTaskExecutor* _threadPool; diff --git a/src/mongo/db/ftdc/ftdc_server.h b/src/mongo/db/ftdc/ftdc_server.h index 265c47dfd54..1d121e0c705 100644 --- a/src/mongo/db/ftdc/ftdc_server.h +++ b/src/mongo/db/ftdc/ftdc_server.h @@ -105,13 +105,13 @@ private: * Used to provide default values from FTDCConfig to the FTDC set parameters. */ struct FTDCStartupParams { - AtomicBool enabled; - AtomicInt32 periodMillis; + AtomicWord<bool> enabled; + AtomicWord<int> periodMillis; - AtomicInt32 maxDirectorySizeMB; - AtomicInt32 maxFileSizeMB; - AtomicInt32 maxSamplesPerArchiveMetricChunk; - AtomicInt32 maxSamplesPerInterimMetricChunk; + AtomicWord<int> maxDirectorySizeMB; + AtomicWord<int> maxFileSizeMB; + AtomicWord<int> maxSamplesPerArchiveMetricChunk; + AtomicWord<int> maxSamplesPerInterimMetricChunk; FTDCStartupParams() : enabled(FTDCConfig::kEnabledDefault), diff --git a/src/mongo/db/index/duplicate_key_tracker.h b/src/mongo/db/index/duplicate_key_tracker.h index e72b1595f86..d8047a7001d 100644 --- a/src/mongo/db/index/duplicate_key_tracker.h +++ b/src/mongo/db/index/duplicate_key_tracker.h @@ -75,7 +75,7 @@ public: private: const IndexCatalogEntry* _indexCatalogEntry; - AtomicInt64 _duplicateCounter{0}; + AtomicWord<long long> _duplicateCounter{0}; // This temporary record store is owned by the duplicate key tracker and dropped along with it. std::unique_ptr<TemporaryRecordStore> _keyConstraintsTable; diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 6a9c4a52d58..081bb8a2ed2 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -821,7 +821,7 @@ SortedDataInterface* AbstractIndexAccessMethod::getSortedDataInterface() const { * places, rather than compiled in one place and linked, and so cannot provide a globally unique ID. */ std::string nextFileName() { - static AtomicUInt32 indexAccessMethodFileCounter; + static AtomicWord<unsigned> indexAccessMethodFileCounter; return "extsort-index." + std::to_string(indexAccessMethodFileCounter.fetchAndAdd(1)); } diff --git a/src/mongo/db/index/index_build_interceptor.h b/src/mongo/db/index/index_build_interceptor.h index 4dccc8d698c..fbfb8c298d2 100644 --- a/src/mongo/db/index/index_build_interceptor.h +++ b/src/mongo/db/index/index_build_interceptor.h @@ -127,7 +127,7 @@ private: int64_t _numApplied{0}; - AtomicInt64 _sideWritesCounter{0}; + AtomicWord<long long> _sideWritesCounter{0}; mutable stdx::mutex _multikeyPathMutex; boost::optional<MultikeyPaths> _multikeyPaths; diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index a3b6fcfe019..75ada6a3b5f 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -55,7 +55,7 @@ namespace mongo { using std::endl; -AtomicUInt32 IndexBuilder::_indexBuildCount; +AtomicWord<unsigned> IndexBuilder::_indexBuildCount; namespace { diff --git a/src/mongo/db/index_builder.h b/src/mongo/db/index_builder.h index 4e11c2ad9ca..0f41d2af579 100644 --- a/src/mongo/db/index_builder.h +++ b/src/mongo/db/index_builder.h @@ -112,6 +112,6 @@ private: const ReplicatedWrites _replicatedWrites; const Timestamp _initIndexTs; std::string _name; // name of this builder, not related to the index - static AtomicUInt32 _indexBuildCount; + static AtomicWord<unsigned> _indexBuildCount; }; } diff --git a/src/mongo/db/logical_session_cache.cpp b/src/mongo/db/logical_session_cache.cpp index 00c82fc936a..25d52406aa2 100644 --- a/src/mongo/db/logical_session_cache.cpp +++ b/src/mongo/db/logical_session_cache.cpp @@ -41,7 +41,8 @@ namespace { const auto getLogicalSessionCache = ServiceContext::declareDecoration<std::unique_ptr<LogicalSessionCache>>(); -const auto getLogicalSessionCacheIsRegistered = ServiceContext::declareDecoration<AtomicBool>(); +const auto getLogicalSessionCacheIsRegistered = + ServiceContext::declareDecoration<AtomicWord<bool>>(); } // namespace LogicalSessionCache::~LogicalSessionCache() = default; diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.cpp b/src/mongo/db/pipeline/document_source_bucket_auto.cpp index 7251d3cc2ef..ae724be941c 100644 --- a/src/mongo/db/pipeline/document_source_bucket_auto.cpp +++ b/src/mongo/db/pipeline/document_source_bucket_auto.cpp @@ -77,7 +77,7 @@ boost::intrusive_ptr<Expression> parseGroupByExpression( * places, rather than compiled in one place and linked, and so cannot provide a globally unique ID. */ std::string nextFileName() { - static AtomicUInt32 documentSourceBucketAutoFileCounter; + static AtomicWord<unsigned> documentSourceBucketAutoFileCounter; return "extsort-doc-bucket." + std::to_string(documentSourceBucketAutoFileCounter.fetchAndAdd(1)); } diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp index 440c6c10ee9..318a67df1ff 100644 --- a/src/mongo/db/pipeline/document_source_group.cpp +++ b/src/mongo/db/pipeline/document_source_group.cpp @@ -59,7 +59,7 @@ namespace { * places, rather than compiled in one place and linked, and so cannot provide a globally unique ID. */ std::string nextFileName() { - static AtomicUInt32 documentSourceGroupFileCounter; + static AtomicWord<unsigned> documentSourceGroupFileCounter; return "extsort-doc-group." + std::to_string(documentSourceGroupFileCounter.fetchAndAdd(1)); } diff --git a/src/mongo/db/pipeline/document_source_out_replace_coll.cpp b/src/mongo/db/pipeline/document_source_out_replace_coll.cpp index d112672f5ea..5f4be9cbfb8 100644 --- a/src/mongo/db/pipeline/document_source_out_replace_coll.cpp +++ b/src/mongo/db/pipeline/document_source_out_replace_coll.cpp @@ -35,7 +35,7 @@ namespace mongo { -static AtomicUInt32 aggOutCounter; +static AtomicWord<unsigned> aggOutCounter; void DocumentSourceOutReplaceColl::initializeWriteNs() { LocalReadConcernBlock readLocal(pExpCtx->opCtx); diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp index 6ba8c9e8e78..475897471ed 100644 --- a/src/mongo/db/pipeline/document_source_sort.cpp +++ b/src/mongo/db/pipeline/document_source_sort.cpp @@ -107,7 +107,7 @@ Value deserializeSortKey(size_t sortPatternSize, BSONObj bsonSortKey) { * places, rather than compiled in one place and linked, and so cannot provide a globally unique ID. */ std::string nextFileName() { - static AtomicUInt32 documentSourceSortFileCounter; + static AtomicWord<unsigned> documentSourceSortFileCounter; return "extsort-doc-source-sort." + std::to_string(documentSourceSortFileCounter.fetchAndAdd(1)); } diff --git a/src/mongo/db/query/expression_index_knobs.h b/src/mongo/db/query/expression_index_knobs.h index 15ad7117da8..4245e97c0d4 100644 --- a/src/mongo/db/query/expression_index_knobs.h +++ b/src/mongo/db/query/expression_index_knobs.h @@ -41,24 +41,24 @@ namespace mongo { /** * The maximum number of cells to use for 2D geo query covering for predicate queries */ -extern AtomicInt32 internalGeoPredicateQuery2DMaxCoveringCells; +extern AtomicWord<int> internalGeoPredicateQuery2DMaxCoveringCells; /** * The maximum number of cells to use for 2D geo query covering for predicate queries */ -extern AtomicInt32 internalGeoNearQuery2DMaxCoveringCells; +extern AtomicWord<int> internalGeoNearQuery2DMaxCoveringCells; // // Geo query. // // What is the finest level we will cover a queried region or geoNear annulus? -extern AtomicInt32 internalQueryS2GeoFinestLevel; +extern AtomicWord<int> internalQueryS2GeoFinestLevel; // What is the coarsest level we will cover a queried region or geoNear annulus? -extern AtomicInt32 internalQueryS2GeoCoarsestLevel; +extern AtomicWord<int> internalQueryS2GeoCoarsestLevel; // What is the maximum cell count that we want? (advisory, not a hard threshold) -extern AtomicInt32 internalQueryS2GeoMaxCells; +extern AtomicWord<int> internalQueryS2GeoMaxCells; } // namespace mongo diff --git a/src/mongo/db/query/query_knobs.h b/src/mongo/db/query/query_knobs.h index 3d050f804b1..976bb1a4ec3 100644 --- a/src/mongo/db/query/query_knobs.h +++ b/src/mongo/db/query/query_knobs.h @@ -41,34 +41,34 @@ namespace mongo { // Max number of times we call work() on plans before comparing them, // for small collections. -extern AtomicInt32 internalQueryPlanEvaluationWorks; +extern AtomicWord<int> internalQueryPlanEvaluationWorks; // For large collections, the number times we work() candidate plans is // taken as this fraction of the collection size. extern AtomicDouble internalQueryPlanEvaluationCollFraction; // Stop working plans once a plan returns this many results. -extern AtomicInt32 internalQueryPlanEvaluationMaxResults; +extern AtomicWord<int> internalQueryPlanEvaluationMaxResults; // Do we give a big ranking bonus to intersection plans? -extern AtomicBool internalQueryForceIntersectionPlans; +extern AtomicWord<bool> internalQueryForceIntersectionPlans; // Do we have ixisect on at all? -extern AtomicBool internalQueryPlannerEnableIndexIntersection; +extern AtomicWord<bool> internalQueryPlannerEnableIndexIntersection; // Do we use hash-based intersection for rooted $and queries? -extern AtomicBool internalQueryPlannerEnableHashIntersection; +extern AtomicWord<bool> internalQueryPlannerEnableHashIntersection; // // plan cache // // How many entries in the cache? -extern AtomicInt32 internalQueryCacheSize; +extern AtomicWord<int> internalQueryCacheSize; // How many feedback entries do we collect before possibly evicting from the cache based on bad // performance? -extern AtomicInt32 internalQueryCacheFeedbacksStored; +extern AtomicWord<int> internalQueryCacheFeedbacksStored; // How many times more works must we perform in order to justify plan cache eviction // and replanning? @@ -79,66 +79,66 @@ extern AtomicDouble internalQueryCacheEvictionRatio; extern AtomicDouble internalQueryCacheWorksGrowthCoefficient; // Whether or not cache entries can be marked as "inactive." -extern AtomicBool internalQueryCacheDisableInactiveEntries; +extern AtomicWord<bool> internalQueryCacheDisableInactiveEntries; // Whether or not planCacheListPlans uses the new output format. -extern AtomicBool internalQueryCacheListPlansNewOutput; +extern AtomicWord<bool> internalQueryCacheListPlansNewOutput; // // Planning and enumeration. // // How many indexed solutions will QueryPlanner::plan output? -extern AtomicInt32 internalQueryPlannerMaxIndexedSolutions; +extern AtomicWord<int> internalQueryPlannerMaxIndexedSolutions; // How many solutions will the enumerator consider at each OR? -extern AtomicInt32 internalQueryEnumerationMaxOrSolutions; +extern AtomicWord<int> internalQueryEnumerationMaxOrSolutions; // How many intersections will the enumerator consider at each AND? -extern AtomicInt32 internalQueryEnumerationMaxIntersectPerAnd; +extern AtomicWord<int> internalQueryEnumerationMaxIntersectPerAnd; // Do we want to plan each child of the OR independently? -extern AtomicBool internalQueryPlanOrChildrenIndependently; +extern AtomicWord<bool> internalQueryPlanOrChildrenIndependently; // How many index scans are we willing to produce in order to obtain a sort order // during explodeForSort? -extern AtomicInt32 internalQueryMaxScansToExplode; +extern AtomicWord<int> internalQueryMaxScansToExplode; // Allow the planner to generate covered whole index scans, rather than falling back to a COLLSCAN. -extern AtomicBool internalQueryPlannerGenerateCoveredWholeIndexScans; +extern AtomicWord<bool> internalQueryPlannerGenerateCoveredWholeIndexScans; // Ignore unknown JSON Schema keywords. -extern AtomicBool internalQueryIgnoreUnknownJSONSchemaKeywords; +extern AtomicWord<bool> internalQueryIgnoreUnknownJSONSchemaKeywords; // // Query execution. // -extern AtomicInt32 internalQueryExecMaxBlockingSortBytes; +extern AtomicWord<int> internalQueryExecMaxBlockingSortBytes; // Yield after this many "should yield?" checks. -extern AtomicInt32 internalQueryExecYieldIterations; +extern AtomicWord<int> internalQueryExecYieldIterations; // Yield if it's been at least this many milliseconds since we last yielded. -extern AtomicInt32 internalQueryExecYieldPeriodMS; +extern AtomicWord<int> internalQueryExecYieldPeriodMS; // Limit the size that we write without yielding to 16MB / 64 (max expected number of indexes) const int64_t insertVectorMaxBytes = 256 * 1024; // The number of bytes to buffer at once during a $facet stage. -extern AtomicInt32 internalQueryFacetBufferSizeBytes; +extern AtomicWord<int> internalQueryFacetBufferSizeBytes; -extern AtomicInt64 internalDocumentSourceSortMaxBlockingSortBytes; +extern AtomicWord<long long> internalDocumentSourceSortMaxBlockingSortBytes; -extern AtomicInt64 internalLookupStageIntermediateDocumentMaxSizeBytes; +extern AtomicWord<long long> internalLookupStageIntermediateDocumentMaxSizeBytes; -extern AtomicInt64 internalDocumentSourceGroupMaxMemoryBytes; +extern AtomicWord<long long> internalDocumentSourceGroupMaxMemoryBytes; -extern AtomicInt32 internalInsertMaxBatchSize; +extern AtomicWord<int> internalInsertMaxBatchSize; -extern AtomicInt32 internalDocumentSourceCursorBatchSizeBytes; +extern AtomicWord<int> internalDocumentSourceCursorBatchSizeBytes; -extern AtomicInt32 internalDocumentSourceLookupCacheSizeBytes; +extern AtomicWord<int> internalDocumentSourceLookupCacheSizeBytes; -extern AtomicBool internalQueryProhibitBlockingMergeOnMongoS; +extern AtomicWord<bool> internalQueryProhibitBlockingMergeOnMongoS; } // namespace mongo diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 28d3266ca82..07173344dee 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -174,7 +174,7 @@ StatusWith<OpTimeWithHash> parseOpTimeWithHash(const QueryResponseStatus& fetchR */ class InitialSyncApplyObserver : public OplogApplier::Observer { public: - explicit InitialSyncApplyObserver(AtomicUInt32* fetchCount) : _fetchCount(fetchCount) {} + explicit InitialSyncApplyObserver(AtomicWord<unsigned>* fetchCount) : _fetchCount(fetchCount) {} // OplogApplier::Observer functions void onBatchBegin(const OplogApplier::Operations&) final {} @@ -184,7 +184,7 @@ public: } private: - AtomicUInt32* const _fetchCount; + AtomicWord<unsigned>* const _fetchCount; }; } // namespace diff --git a/src/mongo/db/repl/initial_syncer.h b/src/mongo/db/repl/initial_syncer.h index 929643116c5..308fdb6adaf 100644 --- a/src/mongo/db/repl/initial_syncer.h +++ b/src/mongo/db/repl/initial_syncer.h @@ -568,7 +568,7 @@ private: void _shutdownComponent_inlock(Component& component); // Counts how many documents have been refetched from the source in the current batch. - AtomicUInt32 _fetchCount; + AtomicWord<unsigned> _fetchCount; // // All member variables are labeled with one of the following codes indicating the diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index 4e29959f1df..765e4559c13 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -594,7 +594,7 @@ private: // during rollback. In order to read it, must have the RSTL. To set it when transitioning // into RS_ROLLBACK, must have the RSTL in mode X. Otherwise, no lock or mutex is necessary // to set it. - AtomicUInt32 _canServeNonLocalReads; + AtomicWord<unsigned> _canServeNonLocalReads; }; void _resetMyLastOpTimes(WithLock lk); @@ -1256,7 +1256,7 @@ private: _initialSyncer; // (I) pointer set under mutex, copied by callers. // Hands out the next snapshot name. - AtomicUInt64 _snapshotNameGenerator; // (S) + AtomicWord<unsigned long long> _snapshotNameGenerator; // (S) // The OpTimes and SnapshotNames for all snapshots newer than the current commit point, kept in // sorted order. Any time this is changed, you must also update _uncommitedSnapshotsSize. @@ -1264,7 +1264,7 @@ private: // A cache of the size of _uncommittedSnaphots that can be read without any locking. // May only be written to while holding _mutex. - AtomicUInt64 _uncommittedSnapshotsSize; // (I) + AtomicWord<unsigned long long> _uncommittedSnapshotsSize; // (I) // The non-null OpTime and SnapshotName of the current snapshot used for committed reads, if // there is one. @@ -1317,7 +1317,7 @@ private: int _earliestMemberId = -1; // (M) // Cached copy of the current config protocol version. - AtomicInt64 _protVersion{1}; // (S) + AtomicWord<long long> _protVersion{1}; // (S) // Source of random numbers used in setting election timeouts, etc. PseudoRandom _random; // (M) @@ -1330,7 +1330,7 @@ private: // function. // This variable must be written immediately after _term, and thus its value can lag. // Reading this value does not require the replication coordinator mutex to be locked. - AtomicInt64 _termShadow; // (S) + AtomicWord<long long> _termShadow; // (S) // When we decide to step down due to hearing about a higher term, we remember the term we heard // here so we can update our term to match as part of finishing stepdown. diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h index a17da59ead1..72d2508ce36 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.h +++ b/src/mongo/db/repl/replication_coordinator_mock.h @@ -289,7 +289,7 @@ public: virtual bool setContainsArbiter() const override; private: - AtomicUInt64 _snapshotNameGenerator; + AtomicWord<unsigned long long> _snapshotNameGenerator; ServiceContext* const _service; ReplSettings _settings; StorageInterface* _storage = nullptr; diff --git a/src/mongo/db/retryable_writes_stats.h b/src/mongo/db/retryable_writes_stats.h index 9bd027f7444..cece6da39ae 100644 --- a/src/mongo/db/retryable_writes_stats.h +++ b/src/mongo/db/retryable_writes_stats.h @@ -63,14 +63,14 @@ public: private: // The number of received commands that contained a statement that had already been executed. - AtomicUInt64 _retriedCommandsCount{0}; + AtomicWord<unsigned long long> _retriedCommandsCount{0}; // The number of received statements found to have been previously executed. - AtomicUInt64 _retriedStatementsCount{0}; + AtomicWord<unsigned long long> _retriedStatementsCount{0}; // The number of writes to the config.transactions collection. Includes writes initiated by a // migration. - AtomicUInt64 _transactionsCollectionWriteCount{0}; + AtomicWord<unsigned long long> _transactionsCollectionWriteCount{0}; }; } // namespace mongo diff --git a/src/mongo/db/s/collection_range_deleter.h b/src/mongo/db/s/collection_range_deleter.h index f6b9f161a47..88f157338a6 100644 --- a/src/mongo/db/s/collection_range_deleter.h +++ b/src/mongo/db/s/collection_range_deleter.h @@ -49,11 +49,11 @@ class OperationContext; // secondaryThrottle and rangeDeleterBatchDelayMS apply between each batch. // Must be positive or 0 (the default), which means to use the value of // internalQueryExecYieldIterations (or 1 if that's negative or zero). -extern AtomicInt32 rangeDeleterBatchSize; +extern AtomicWord<int> rangeDeleterBatchSize; // After completing a batch of document deletions, the time in millis to wait before commencing the // next batch of deletions. -extern AtomicInt32 rangeDeleterBatchDelayMS; +extern AtomicWord<int> rangeDeleterBatchDelayMS; class CollectionRangeDeleter { MONGO_DISALLOW_COPYING(CollectionRangeDeleter); diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp index 038c2447c06..38a55e6f195 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp @@ -56,7 +56,7 @@ using CollectionAndChangedChunks = CatalogCacheLoader::CollectionAndChangedChunk namespace { -AtomicUInt64 taskIdGenerator{0}; +AtomicWord<unsigned long long> taskIdGenerator{0}; /** * Constructs the options for the loader thread pool. diff --git a/src/mongo/db/s/sharding_logging.h b/src/mongo/db/s/sharding_logging.h index 3407809d9a4..30c60d5b8bd 100644 --- a/src/mongo/db/s/sharding_logging.h +++ b/src/mongo/db/s/sharding_logging.h @@ -101,10 +101,10 @@ private: // (S) Self-synchronizing; access in any way from any context. // Whether the logAction call should attempt to create the actionlog collection - AtomicInt32 _actionLogCollectionCreated{0}; // (S) + AtomicWord<int> _actionLogCollectionCreated{0}; // (S) // Whether the logChange call should attempt to create the changelog collection - AtomicInt32 _changeLogCollectionCreated{0}; // (S) + AtomicWord<int> _changeLogCollectionCreated{0}; // (S) }; } // namespace mongo diff --git a/src/mongo/db/s/sharding_state.h b/src/mongo/db/s/sharding_state.h index fb220c9aaea..11b042a2cc9 100644 --- a/src/mongo/db/s/sharding_state.h +++ b/src/mongo/db/s/sharding_state.h @@ -146,7 +146,7 @@ private: stdx::mutex _mutex; // State of the initialization of the sharding state along with any potential errors - AtomicUInt32 _initializationState{static_cast<uint32_t>(InitializationState::kNew)}; + AtomicWord<unsigned> _initializationState{static_cast<uint32_t>(InitializationState::kNew)}; // Sets the shard name for this host (comes through setShardVersion) ShardId _shardId; diff --git a/src/mongo/db/s/sharding_statistics.h b/src/mongo/db/s/sharding_statistics.h index d6dee68c607..8154a67d7a8 100644 --- a/src/mongo/db/s/sharding_statistics.h +++ b/src/mongo/db/s/sharding_statistics.h @@ -44,40 +44,40 @@ class ServiceContext; struct ShardingStatistics { // Counts how many times threads hit stale config exception (which is what triggers metadata // refreshes). - AtomicInt64 countStaleConfigErrors{0}; + AtomicWord<long long> countStaleConfigErrors{0}; // Cumulative, always-increasing counter of how many chunks this node has started to donate // (whether they succeeded or not). - AtomicInt64 countDonorMoveChunkStarted{0}; + AtomicWord<long long> countDonorMoveChunkStarted{0}; // Cumulative, always-increasing counter of how much time the entire move chunk operation took // (excluding range deletion). - AtomicInt64 totalDonorMoveChunkTimeMillis{0}; + AtomicWord<long long> totalDonorMoveChunkTimeMillis{0}; // Cumulative, always-increasing counter of how much time the clone phase took on the donor // node, before it was appropriate to enter the critical section. - AtomicInt64 totalDonorChunkCloneTimeMillis{0}; + AtomicWord<long long> totalDonorChunkCloneTimeMillis{0}; // Cumulative, always-increasing counter of how many documents have been cloned on the // recipient node. - AtomicInt64 countDocsClonedOnRecipient{0}; + AtomicWord<long long> countDocsClonedOnRecipient{0}; // Cumulative, always-increasing counter of how many documents have been cloned on the donor // node. - AtomicInt64 countDocsClonedOnDonor{0}; + AtomicWord<long long> countDocsClonedOnDonor{0}; // Cumulative, always-increasing counter of how many documents have been deleted on the donor // node by the rangeDeleter. - AtomicInt64 countDocsDeletedOnDonor{0}; + AtomicWord<long long> countDocsDeletedOnDonor{0}; // Cumulative, always-increasing counter of how many chunks this node started to receive // (whether the receiving succeeded or not) - AtomicInt64 countRecipientMoveChunkStarted{0}; + AtomicWord<long long> countRecipientMoveChunkStarted{0}; // Cumulative, always-increasing counter of how much time the critical section's commit phase // took (this is the period of time when all operations on the collection are blocked, not just // the reads) - AtomicInt64 totalCriticalSectionCommitTimeMillis{0}; + AtomicWord<long long> totalCriticalSectionCommitTimeMillis{0}; // Cumulative, always-increasing counter of how much time the entire critical section took. It // includes the time the recipient took to fetch the latest modifications from the donor and @@ -86,7 +86,7 @@ struct ShardingStatistics { // The value of totalCriticalSectionTimeMillis - totalCriticalSectionCommitTimeMillis gives the // duration of the catch-up phase of the critical section (where the last mods are transferred // from the donor to the recipient). - AtomicInt64 totalCriticalSectionTimeMillis{0}; + AtomicWord<long long> totalCriticalSectionTimeMillis{0}; /** * Obtains the per-process instance of the sharding statistics object. diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 5a0d7ce18c0..de76672f6e0 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -61,7 +61,7 @@ struct ServerGlobalParams { bool indexBuildRetry = true; // --noIndexBuildRetry - AtomicBool quiet{false}; // --quiet + AtomicWord<bool> quiet{false}; // --quiet ClusterRole clusterRole = ClusterRole::None; // --configsvr/--shardsvr @@ -121,8 +121,8 @@ struct ServerGlobalParams { AuthState authState = AuthState::kUndefined; - bool transitionToAuth = false; // --transitionToAuth, mixed mode for rolling auth upgrade - AtomicInt32 clusterAuthMode; // --clusterAuthMode, the internal cluster auth mode + bool transitionToAuth = false; // --transitionToAuth, mixed mode for rolling auth upgrade + AtomicWord<int> clusterAuthMode; // --clusterAuthMode, the internal cluster auth mode enum ClusterAuthModes { ClusterAuthMode_undefined, diff --git a/src/mongo/db/server_parameters_test.cpp b/src/mongo/db/server_parameters_test.cpp index 88fc191ab90..34d0d8e8b36 100644 --- a/src/mongo/db/server_parameters_test.cpp +++ b/src/mongo/db/server_parameters_test.cpp @@ -202,7 +202,7 @@ TEST(ServerParameters, boundIntLock) { } TEST(ServerParameters, Simple1) { - AtomicInt32 f(5); + AtomicWord<int> f(5); ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime> ff(NULL, "ff", &f); ASSERT_EQUALS("ff", ff.name()); @@ -247,7 +247,7 @@ TEST(ServerParameters, Vector1) { } TEST(ServerParameters, Validators) { - AtomicInt32 myVal(0); + AtomicWord<int> myVal(0); ExportedServerParameter<int, ServerParameterType::kRuntimeOnly> myParam( nullptr, "myVal", &myVal); myParam.withValidator([](const int& newVal) { diff --git a/src/mongo/db/server_transactions_metrics.h b/src/mongo/db/server_transactions_metrics.h index 4f46e9ff03b..e0979dd6d67 100644 --- a/src/mongo/db/server_transactions_metrics.h +++ b/src/mongo/db/server_transactions_metrics.h @@ -174,34 +174,34 @@ private: mutable stdx::mutex _mutex; // The number of multi-document transactions currently active. - AtomicUInt64 _currentActive{0}; + AtomicWord<unsigned long long> _currentActive{0}; // The number of multi-document transactions currently inactive. - AtomicUInt64 _currentInactive{0}; + AtomicWord<unsigned long long> _currentInactive{0}; // The total number of open transactions. - AtomicUInt64 _currentOpen{0}; + AtomicWord<unsigned long long> _currentOpen{0}; // The total number of multi-document transactions started since the last server startup. - AtomicUInt64 _totalStarted{0}; + AtomicWord<unsigned long long> _totalStarted{0}; // The total number of multi-document transaction aborts. - AtomicUInt64 _totalAborted{0}; + AtomicWord<unsigned long long> _totalAborted{0}; // The total number of multi-document transaction commits. - AtomicUInt64 _totalCommitted{0}; + AtomicWord<unsigned long long> _totalCommitted{0}; // The total number of prepared transactions since the last server startup. - AtomicUInt64 _totalPrepared{0}; + AtomicWord<unsigned long long> _totalPrepared{0}; // The total number of prepared transaction commits. - AtomicUInt64 _totalPreparedThenCommitted{0}; + AtomicWord<unsigned long long> _totalPreparedThenCommitted{0}; // The total number of prepared transaction aborts. - AtomicUInt64 _totalPreparedThenAborted{0}; + AtomicWord<unsigned long long> _totalPreparedThenAborted{0}; // The current number of transactions in the prepared state. - AtomicUInt64 _currentPrepared{0}; + AtomicWord<unsigned long long> _currentPrepared{0}; // The optime of the oldest oplog entry for any active transaction. boost::optional<repl::OpTime> _oldestActiveOplogEntryOpTime; // (M) diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index 97b4de476c1..32f2351444c 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -583,7 +583,7 @@ private: std::vector<KillOpListenerInterface*> _killOpListeners; // Counter for assigning operation ids. - AtomicUInt32 _nextOpId{1}; + AtomicWord<unsigned> _nextOpId{1}; bool _startupComplete = false; stdx::condition_variable _startupCompleteCondVar; diff --git a/src/mongo/db/snapshot_window_options.h b/src/mongo/db/snapshot_window_options.h index 6944e78e18f..5ede44532ee 100644 --- a/src/mongo/db/snapshot_window_options.h +++ b/src/mongo/db/snapshot_window_options.h @@ -49,7 +49,7 @@ struct SnapshotWindowParams { // // Note that the window size can become greater than this if an ongoing operation is holding an // older snapshot open. - AtomicInt32 maxTargetSnapshotHistoryWindowInSeconds{5}; + AtomicWord<int> maxTargetSnapshotHistoryWindowInSeconds{5}; // targetSnapshotHistoryWindowInSeconds (not a server parameter, range 0+). // @@ -60,7 +60,7 @@ struct SnapshotWindowParams { // not always reflect it: the window can only change as more writes come in, so it can take time // for the actual window size to catch up with a change. This value guides actions whenever the // system goes to update the oldest_timestamp value. - AtomicInt32 targetSnapshotHistoryWindowInSeconds{ + AtomicWord<int> targetSnapshotHistoryWindowInSeconds{ maxTargetSnapshotHistoryWindowInSeconds.load()}; // cachePressureThreshold (startup & runtime server paramter, range [0, 100]). @@ -70,7 +70,7 @@ struct SnapshotWindowParams { // targetSnapshotHistoryWindowInSeconds will be ignored when the cache pressure reaches this // threshold. Additionally, a periodic task will decrease targetSnapshotHistoryWindowInSeconds // when cache pressure exceeds the threshold. - AtomicInt32 cachePressureThreshold{50}; + AtomicWord<int> cachePressureThreshold{50}; // snapshotWindowMultiplicativeDecrease (startup & runtime server paramter, range (0,1)). // @@ -83,7 +83,7 @@ struct SnapshotWindowParams { // Controls by how much the target snapshot history window setting is increased when cache // pressure is OK, per cachePressureThreshold, and we need to service older snapshots for global // point-in-time reads. - AtomicInt32 snapshotWindowAdditiveIncreaseSeconds{2}; + AtomicWord<int> snapshotWindowAdditiveIncreaseSeconds{2}; // minMillisBetweenSnapshotWindowInc (startup & runtime server paramter, range 0+). // minMillisBetweenSnapshotWindowDec (startup & runtime server paramter, range 0+). @@ -93,8 +93,8 @@ struct SnapshotWindowParams { // as one. This protects the system because it takes time for the target snapshot window to // affect the actual storage engine snapshot window. The stable timestamp must move forward for // the window between it and oldest timestamp to grow or shrink. - AtomicInt32 minMillisBetweenSnapshotWindowInc{500}; - AtomicInt32 minMillisBetweenSnapshotWindowDec{500}; + AtomicWord<int> minMillisBetweenSnapshotWindowInc{500}; + AtomicWord<int> minMillisBetweenSnapshotWindowDec{500}; // checkCachePressurePeriodSeconds (startup & runtime server paramter, range 1+) // @@ -102,7 +102,7 @@ struct SnapshotWindowParams { // targetSnapshotHistoryWindowInSeconds if the pressure is above cachePressureThreshold. The // target window size setting must not be decreased too fast because time must be allowed for // the storage engine to attempt to act on the new setting. - AtomicInt32 checkCachePressurePeriodSeconds{5}; + AtomicWord<int> checkCachePressurePeriodSeconds{5}; }; extern SnapshotWindowParams snapshotWindowParams; diff --git a/src/mongo/db/sorter/sorter_test.cpp b/src/mongo/db/sorter/sorter_test.cpp index a154912ecce..b11a8abf637 100644 --- a/src/mongo/db/sorter/sorter_test.cpp +++ b/src/mongo/db/sorter/sorter_test.cpp @@ -59,7 +59,7 @@ namespace mongo { * places, rather than compiled in one place and linked, and so cannot provide a globally unique ID. */ std::string nextFileName() { - static AtomicUInt32 sorterTestFileCounter; + static AtomicWord<unsigned> sorterTestFileCounter; return "extsort-sorter-test." + std::to_string(sorterTestFileCounter.fetchAndAdd(1)); } diff --git a/src/mongo/db/stats/counters.cpp b/src/mongo/db/stats/counters.cpp index 0355fa8787b..406385b28c9 100644 --- a/src/mongo/db/stats/counters.cpp +++ b/src/mongo/db/stats/counters.cpp @@ -68,8 +68,8 @@ void OpCounters::gotOp(int op, bool isCommand) { } } -void OpCounters::_checkWrap(CacheAligned<AtomicInt64> OpCounters::*counter, int n) { - static constexpr auto maxCount = AtomicInt64::WordType{1} << 60; +void OpCounters::_checkWrap(CacheAligned<AtomicWord<long long>> OpCounters::*counter, int n) { + static constexpr auto maxCount = 1LL << 60; auto oldValue = (this->*counter).fetchAndAddRelaxed(n); if (oldValue > maxCount) { _insert.store(0); diff --git a/src/mongo/db/stats/counters.h b/src/mongo/db/stats/counters.h index 4d6a057e427..699dbb43b12 100644 --- a/src/mongo/db/stats/counters.h +++ b/src/mongo/db/stats/counters.h @@ -76,35 +76,35 @@ public: BSONObj getObj() const; // thse are used by snmp, and other things, do not remove - const AtomicInt64* getInsert() const { + const AtomicWord<long long>* getInsert() const { return &_insert; } - const AtomicInt64* getQuery() const { + const AtomicWord<long long>* getQuery() const { return &_query; } - const AtomicInt64* getUpdate() const { + const AtomicWord<long long>* getUpdate() const { return &_update; } - const AtomicInt64* getDelete() const { + const AtomicWord<long long>* getDelete() const { return &_delete; } - const AtomicInt64* getGetMore() const { + const AtomicWord<long long>* getGetMore() const { return &_getmore; } - const AtomicInt64* getCommand() const { + const AtomicWord<long long>* getCommand() const { return &_command; } private: // Increment member `counter` by `n`, resetting all counters if it was > 2^60. - void _checkWrap(CacheAligned<AtomicInt64> OpCounters::*counter, int n); - - CacheAligned<AtomicInt64> _insert; - CacheAligned<AtomicInt64> _query; - CacheAligned<AtomicInt64> _update; - CacheAligned<AtomicInt64> _delete; - CacheAligned<AtomicInt64> _getmore; - CacheAligned<AtomicInt64> _command; + void _checkWrap(CacheAligned<AtomicWord<long long>> OpCounters::*counter, int n); + + CacheAligned<AtomicWord<long long>> _insert; + CacheAligned<AtomicWord<long long>> _query; + CacheAligned<AtomicWord<long long>> _update; + CacheAligned<AtomicWord<long long>> _delete; + CacheAligned<AtomicWord<long long>> _getmore; + CacheAligned<AtomicWord<long long>> _command; }; extern OpCounters globalOpCounters; @@ -124,20 +124,20 @@ public: void append(BSONObjBuilder& b); private: - CacheAligned<AtomicInt64> _physicalBytesIn{0}; - CacheAligned<AtomicInt64> _physicalBytesOut{0}; + CacheAligned<AtomicWord<long long>> _physicalBytesIn{0}; + CacheAligned<AtomicWord<long long>> _physicalBytesOut{0}; // These two counters are always incremented at the same time, so // we place them on the same cache line. struct Together { - AtomicInt64 logicalBytesIn{0}; - AtomicInt64 requests{0}; + AtomicWord<long long> logicalBytesIn{0}; + AtomicWord<long long> requests{0}; }; CacheAligned<Together> _together{}; static_assert(sizeof(decltype(_together)) <= stdx::hardware_constructive_interference_size, "cache line spill"); - CacheAligned<AtomicInt64> _logicalBytesOut{0}; + CacheAligned<AtomicWord<long long>> _logicalBytesOut{0}; }; extern NetworkCounter networkCounter; diff --git a/src/mongo/db/stats/timer_stats.h b/src/mongo/db/stats/timer_stats.h index f1153f90ba5..31cbfeba9cb 100644 --- a/src/mongo/db/stats/timer_stats.h +++ b/src/mongo/db/stats/timer_stats.h @@ -58,8 +58,8 @@ public: } private: - AtomicInt64 _num; - AtomicInt64 _totalMillis; + AtomicWord<long long> _num; + AtomicWord<long long> _totalMillis; }; /** diff --git a/src/mongo/db/storage/biggie/biggie_record_store.h b/src/mongo/db/storage/biggie/biggie_record_store.h index cfbaf67e8eb..ccdd5bc28b3 100644 --- a/src/mongo/db/storage/biggie/biggie_record_store.h +++ b/src/mongo/db/storage/biggie/biggie_record_store.h @@ -141,8 +141,8 @@ private: mutable stdx::mutex _cappedDeleterMutex; - AtomicInt64 _highest_record_id{1}; - AtomicInt64 _numRecords{0}; + AtomicWord<long long> _highest_record_id{1}; + AtomicWord<long long> _numRecords{0}; std::string generateKey(const uint8_t* key, size_t key_len) const; bool _isOplog; diff --git a/src/mongo/db/storage/kv/kv_catalog.h b/src/mongo/db/storage/kv/kv_catalog.h index fe670d3795a..05eff5ed241 100644 --- a/src/mongo/db/storage/kv/kv_catalog.h +++ b/src/mongo/db/storage/kv/kv_catalog.h @@ -143,7 +143,7 @@ private: // These two are only used for ident generation inside _newUniqueIdent. std::string _rand; // effectively const after init() returns - AtomicUInt64 _next; + AtomicWord<unsigned long long> _next; struct Entry { Entry() {} diff --git a/src/mongo/db/storage/mobile/mobile_record_store.h b/src/mongo/db/storage/mobile/mobile_record_store.h index 0c31e35cd13..efab31d1c6d 100644 --- a/src/mongo/db/storage/mobile/mobile_record_store.h +++ b/src/mongo/db/storage/mobile/mobile_record_store.h @@ -163,7 +163,7 @@ private: const std::string _path; const std::string _ident; - AtomicInt64 _nextIdNum; + AtomicWord<long long> _nextIdNum; /** * Fetches the number of records from the database. _numRecsMutex should be locked before this diff --git a/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp b/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp index cc169d956d8..97f30ccbcb7 100644 --- a/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp +++ b/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp @@ -46,7 +46,7 @@ namespace mongo { -AtomicInt64 MobileRecoveryUnit::_nextID(0); +AtomicWord<long long> MobileRecoveryUnit::_nextID(0); MobileRecoveryUnit::MobileRecoveryUnit(MobileSessionPool* sessionPool) : _inUnitOfWork(false), _active(false), _isReadOnly(true), _sessionPool(sessionPool) { diff --git a/src/mongo/db/storage/mobile/mobile_recovery_unit.h b/src/mongo/db/storage/mobile/mobile_recovery_unit.h index 982c0c70139..93620fe876c 100644 --- a/src/mongo/db/storage/mobile/mobile_recovery_unit.h +++ b/src/mongo/db/storage/mobile/mobile_recovery_unit.h @@ -99,7 +99,7 @@ private: bool _inUnitOfWork; bool _active; - static AtomicInt64 _nextID; + static AtomicWord<long long> _nextID; uint64_t _id; bool _isReadOnly; diff --git a/src/mongo/db/storage/mobile/mobile_session_pool.h b/src/mongo/db/storage/mobile/mobile_session_pool.h index 2c9b0595de9..1c57ee45f63 100644 --- a/src/mongo/db/storage/mobile/mobile_session_pool.h +++ b/src/mongo/db/storage/mobile/mobile_session_pool.h @@ -57,7 +57,7 @@ public: bool isEmpty(); private: - AtomicBool _isEmpty; + AtomicWord<bool> _isEmpty; stdx::mutex _queueMutex; std::queue<std::string> _opQueryQueue; }; diff --git a/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp b/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp index 0b26d25e1e7..c0ebcfa6f9f 100644 --- a/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp +++ b/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp @@ -46,7 +46,7 @@ namespace mongo { -AtomicInt64 SqliteStatement::_nextID(0); +AtomicWord<long long> SqliteStatement::_nextID(0); SqliteStatement::SqliteStatement(const MobileSession& session, const std::string& sqlQuery) { // Increment the global instance count and assign this instance an id. diff --git a/src/mongo/db/storage/mobile/mobile_sqlite_statement.h b/src/mongo/db/storage/mobile/mobile_sqlite_statement.h index 719bc49a895..87996927902 100644 --- a/src/mongo/db/storage/mobile/mobile_sqlite_statement.h +++ b/src/mongo/db/storage/mobile/mobile_sqlite_statement.h @@ -131,7 +131,7 @@ public: uint64_t _id; private: - static AtomicInt64 _nextID; + static AtomicWord<long long> _nextID; sqlite3_stmt* _stmt; std::string _sqlQuery; diff --git a/src/mongo/db/storage/storage_options.h b/src/mongo/db/storage/storage_options.h index de4bac61aa5..d2486a66858 100644 --- a/src/mongo/db/storage/storage_options.h +++ b/src/mongo/db/storage/storage_options.h @@ -79,11 +79,11 @@ struct StorageGlobalParams { // --journalCommitInterval static const int kMaxJournalCommitIntervalMs; - AtomicInt32 journalCommitIntervalMs; + AtomicWord<int> journalCommitIntervalMs; // --notablescan // no table scans allowed - AtomicBool noTableScan; + AtomicWord<bool> noTableScan; // --directoryperdb // Stores each database’s files in its own folder in the data directory. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index a3c62668e37..97b2f052ed3 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -209,7 +209,7 @@ public: private: WiredTigerSessionCache* _sessionCache; - AtomicBool _shuttingDown{false}; + AtomicWord<bool> _shuttingDown{false}; }; class WiredTigerKVEngine::WiredTigerCheckpointThread : public BackgroundJob { @@ -373,7 +373,7 @@ private: // taking checkpoints. It can be triggered early to expediate immediate checkpointing. stdx::condition_variable _condvar; - AtomicBool _shuttingDown{false}; + AtomicWord<bool> _shuttingDown{false}; bool _hasTriggeredFirstStableCheckpoint = false; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h index ef5980de8d1..3a84c939dfc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h @@ -104,6 +104,6 @@ private: // journal flushing should not be delayed. std::int64_t _opsWaitingForVisibility = 0; // Guarded by oplogVisibilityStateMutex. - AtomicUInt64 _oplogReadTimestamp; + AtomicWord<unsigned long long> _oplogReadTimestamp; }; } // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index 9cc17eb0b00..cc3ae0cefb9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -349,8 +349,8 @@ private: const int64_t _cappedMaxSizeSlack; // when to start applying backpressure const int64_t _cappedMaxDocs; RecordId _cappedFirstRecord; - AtomicInt64 _cappedSleep; - AtomicInt64 _cappedSleepMS; + AtomicWord<long long> _cappedSleep; + AtomicWord<long long> _cappedSleepMS; CappedCallback* _cappedCallback; bool _shuttingDown; mutable stdx::mutex _cappedCallbackMutex; // guards _cappedCallback and _shuttingDown @@ -359,7 +359,7 @@ private: int _cappedDeleteCheckCount; mutable stdx::timed_mutex _cappedDeleterMutex; - AtomicInt64 _nextIdNum; + AtomicWord<long long> _nextIdNum; WiredTigerSizeStorer* _sizeStorer; // not owned, can be NULL std::shared_ptr<WiredTigerSizeStorer::SizeInfo> _sizeInfo; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_oplog_stones.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_oplog_stones.h index 600b92836ec..612b964240f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_oplog_stones.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_oplog_stones.h @@ -141,8 +141,8 @@ private: // deque of oplog stones. int64_t _minBytesPerStone; - AtomicInt64 _currentRecords; // Number of records in the stone being filled. - AtomicInt64 _currentBytes; // Number of bytes in the stone being filled. + AtomicWord<long long> _currentRecords; // Number of records in the stone being filled. + AtomicWord<long long> _currentBytes; // Number of bytes in the stone being filled. mutable stdx::mutex _mutex; // Protects against concurrent access to the deque of oplog stones. std::deque<OplogStones::Stone> _stones; // front = oldest, back = newest. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index b2a4949f5db..e65b027686e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -58,7 +58,7 @@ MONGO_FAIL_POINT_DEFINE(WTAlwaysNotifyPrepareConflictWaiters); // SnapshotIds need to be globally unique, as they are used in a WorkingSetMember to // determine if documents changed, but a different recovery unit may be used across a getMore, // so there is a chance the snapshot ID will be reused. -AtomicUInt64 nextSnapshotId{1}; +AtomicWord<unsigned long long> nextSnapshotId{1}; logger::LogSeverity kSlowTransactionSeverity = logger::LogSeverity::Debug(1); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 3cbdb0a075e..9c0fe8078ba 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -76,7 +76,7 @@ namespace mongo { // will be cached in WiredTiger. Exclusive operations should only be blocked // for a short time, except if a cursor is held by a long running session. This // is a good compromise for most workloads. -AtomicInt32 kWiredTigerCursorCacheSize(-100); +AtomicWord<int> kWiredTigerCursorCacheSize(-100); const std::string kWTRepairMsg = "Please read the documentation for starting MongoDB with --repair here: " @@ -216,7 +216,7 @@ void WiredTigerSession::closeCursorsForQueuedDrops(WiredTigerKVEngine* engine) { } namespace { -AtomicUInt64 nextTableId(1); +AtomicWord<unsigned long long> nextTableId(1); } // static uint64_t WiredTigerSession::genTableId() { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h index 1d91d28f799..7a87cef036e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h @@ -293,7 +293,7 @@ private: // Used as follows: // The low 31 bits are a count of active calls to releaseSession. // The high bit is a flag that is set if and only if we're shutting down. - AtomicUInt32 _shuttingDown; + AtomicWord<unsigned> _shuttingDown; static const uint32_t kShuttingDownMask = 1 << 31; stdx::mutex _cacheLock; @@ -301,13 +301,13 @@ private: SessionCache _sessions; // Bumped when all open sessions need to be closed - AtomicUInt64 _epoch; // atomic so we can check it outside of the lock + AtomicWord<unsigned long long> _epoch; // atomic so we can check it outside of the lock // Bumped when all open cursors need to be closed - AtomicUInt64 _cursorEpoch; // atomic so we can check it outside of the lock + AtomicWord<unsigned long long> _cursorEpoch; // atomic so we can check it outside of the lock // Counter and critical section mutex for waitUntilDurable - AtomicUInt32 _lastSyncTime; + AtomicWord<unsigned> _lastSyncTime; stdx::mutex _lastSyncMutex; // Mutex and cond var for waiting on prepare commit or abort. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h index f1ab4655ee4..3ded5e83c92 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h @@ -68,12 +68,12 @@ public: ~SizeInfo() { invariant(!_dirty.load()); } - AtomicInt64 numRecords; - AtomicInt64 dataSize; + AtomicWord<long long> numRecords; + AtomicWord<long long> dataSize; private: friend WiredTigerSizeStorer; - AtomicBool _dirty; + AtomicWord<bool> _dirty; }; WiredTigerSizeStorer(WT_CONNECTION* conn, diff --git a/src/mongo/db/transaction_coordinator_driver.h b/src/mongo/db/transaction_coordinator_driver.h index fd6bfca2e8c..df08928efcd 100644 --- a/src/mongo/db/transaction_coordinator_driver.h +++ b/src/mongo/db/transaction_coordinator_driver.h @@ -244,7 +244,7 @@ private: ThreadPool* const _pool; // TODO (SERVER-38522): Remove once AsyncWorkScheduler is used for cancellation - AtomicBool _cancelled{false}; + AtomicWord<bool> _cancelled{false}; }; } // namespace mongo diff --git a/src/mongo/db/transaction_participant.h b/src/mongo/db/transaction_participant.h index b8ac97b7e5f..6334090f4a0 100644 --- a/src/mongo/db/transaction_participant.h +++ b/src/mongo/db/transaction_participant.h @@ -56,7 +56,7 @@ namespace mongo { class OperationContext; -extern AtomicInt32 transactionLifetimeLimitSeconds; +extern AtomicWord<int> transactionLifetimeLimitSeconds; /** * Read timestamp to be used for a speculative transaction. For transactions with read diff --git a/src/mongo/db/views/view_catalog.h b/src/mongo/db/views/view_catalog.h index 5a01bda0943..ebede346dd4 100644 --- a/src/mongo/db/views/view_catalog.h +++ b/src/mongo/db/views/view_catalog.h @@ -178,7 +178,7 @@ private: stdx::mutex _mutex; // Protects all members, except for _valid. ViewMap _viewMap; DurableViewCatalog* _durable; - AtomicBool _valid; + AtomicWord<bool> _valid; ViewGraph _viewGraph; bool _viewGraphNeedsRefresh = true; // Defers initializing the graph until the first insert. }; |