[SERVER-25932] Make MONGO_EXPORT_SERVER_PARAMETER work with AtomicWord<T> Created: 01/Sep/16  Updated: 05/Apr/17  Resolved: 05/Jan/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 3.5.2

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-01-23
Participants:

 Description   

The linter will complain if you use std::atomic<T>, suggesting AtomicWord<T> instead. However, the MONGO_EXPORT_SERVER_PARAMTER macro does not work with an AtomicWord<T> type, requiring all parameters that want to use this macro to be declared with a // NOLINT.

Here's an example of the error I got when trying to declare a server parameter with type AtomicInt32:

src/mongo/db/query/query_knobs.cpp:70:31: error: redefinition of 'internalQueryFacetBufferSizeBytes' with a different type: 'server_parameter_storage_type<AtomicInt32,
      ServerParameterType::kStartupAndRuntime>::value_type' (aka 'atomic<mongo::AtomicWord<int> >') vs 'AtomicInt32' (aka 'AtomicWord<int>')
MONGO_EXPORT_SERVER_PARAMETER(internalQueryFacetBufferSizeBytes, AtomicInt32, 100 * 1024 * 1024);
                              ^
src/mongo/db/query/query_knobs.h:113:20: note: previous declaration is here
extern AtomicInt32 internalQueryFacetBufferSizeBytes;  // NOLINT
                   ^
In file included from src/mongo/db/query/query_knobs.cpp:31:
src/mongo/db/server_parameters.h:195:5: error: static_assert failed "This type is not supported as a runtime server parameter."
    static_assert(paramType == ServerParameterType::kStartupOnly ||
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongo/db/query/query_knobs.cpp:70:1: note: in instantiation of template class 'mongo::ExportedServerParameter<mongo::AtomicWord<int>, mongo::ServerParameterType::kStartupAndRuntime>' requested here
MONGO_EXPORT_SERVER_PARAMETER(internalQueryFacetBufferSizeBytes, AtomicInt32, 100 * 1024 * 1024);
^
src/mongo/db/server_parameters.h:246:5: note: expanded from macro 'MONGO_EXPORT_SERVER_PARAMETER'
    MONGO_EXPORT_SERVER_PARAMETER_IMPL(                          \
    ^
src/mongo/db/server_parameters.h:239:47: note: expanded from macro 'MONGO_EXPORT_SERVER_PARAMETER_IMPL'
    ExportedServerParameter<TYPE, PARAM_TYPE> _##NAME(ServerParameterSet::getGlobal(), #NAME, &NAME)
                                              ^
<scratch space>:153:1: note: expanded from here
_internalQueryFacetBufferSizeBytes
^
2 errors generated.
scons: *** [build/opt/mongo/db/query/query_knobs.os] Error 1
scons: building terminated because of errors.
build/opt/mongo/db/query/query_knobs.os failed: Error 1
                                                                                          



 Comments   
Comment by Githook User [ 05/Jan/17 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-25932 Make MONGO_EXPORT_SERVER_PARAMETER use AtomicWord instead of std::atomic
Branch: master
https://github.com/mongodb/mongo/commit/ba55f2573976ba570c2319bce9b598f0a660445f

Comment by Githook User [ 05/Jan/17 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-25932 Make MONGO_EXPORT_SERVER_PARAMETER use AtomicWord instead of std::atomic
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/da3877a172294e9716d4f95a4119eb267fe462b1

Generated at Thu Feb 08 04:10:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.