-
Type:
Improvement
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
Platforms 2017-01-23
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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