Revert "SERVER-105043 LLVM 22 lint and format"

GitOrigin-RevId: 0244d545e453b3f667051f71ca643a821afaf84b
This commit is contained in:
Daniel Moody 2026-05-18 16:07:54 +00:00 committed by MongoDB Bot
parent a8826bd5d7
commit bd87181dd2
100 changed files with 632 additions and 326 deletions

4
MODULE.bazel.lock generated
View File

@ -249,7 +249,7 @@
"moduleExtensions": { "moduleExtensions": {
"//bazel:bzlmod.bzl%bazel_features_deps": { "//bazel:bzlmod.bzl%bazel_features_deps": {
"general": { "general": {
"bzlTransitiveDigest": "G/WD+JnQT596GnXuqRV363uynmjbkk1qeefCHRtgT3Y=", "bzlTransitiveDigest": "dfSpTD7th7o+ah0Usp81y/clMRt3Eyfz/Ey59BcBl68=",
"usagesDigest": "c91kQ0HotoA1cfwWU4KaqCoQU7lT6pGi6XPGIiMGkb0=", "usagesDigest": "c91kQ0HotoA1cfwWU4KaqCoQU7lT6pGi6XPGIiMGkb0=",
"recordedFileInputs": {}, "recordedFileInputs": {},
"recordedDirentsInputs": {}, "recordedDirentsInputs": {},
@ -356,7 +356,7 @@
}, },
"//bazel:bzlmod.bzl%setup_mongo_python_toolchains": { "//bazel:bzlmod.bzl%setup_mongo_python_toolchains": {
"general": { "general": {
"bzlTransitiveDigest": "G/WD+JnQT596GnXuqRV363uynmjbkk1qeefCHRtgT3Y=", "bzlTransitiveDigest": "dfSpTD7th7o+ah0Usp81y/clMRt3Eyfz/Ey59BcBl68=",
"usagesDigest": "bUxjq9n+hj2YwYT/lcSP4lHyQ2GVy5JpFgSmddUqUZg=", "usagesDigest": "bUxjq9n+hj2YwYT/lcSP4lHyQ2GVy5JpFgSmddUqUZg=",
"recordedFileInputs": {}, "recordedFileInputs": {},
"recordedDirentsInputs": {}, "recordedDirentsInputs": {},

View File

@ -426,12 +426,29 @@ TEST(Ostream, StringDataMatchesStdString) {
std::function<void(std::ostream&)> manip; std::function<void(std::ostream&)> manip;
}; };
const TestCase testCases[] = { const TestCase testCases[] = {
{__LINE__, [](std::ostream& os) {}}, {__LINE__,
{__LINE__, [](std::ostream& os) { os << std::setw(5); }}, [](std::ostream& os) {
{__LINE__, [](std::ostream& os) { os << std::left << std::setw(5); }}, }},
{__LINE__, [](std::ostream& os) { os << std::right << std::setw(5); }}, {__LINE__,
{__LINE__, [](std::ostream& os) { os << std::setfill('.') << std::left << std::setw(5); }}, [](std::ostream& os) {
{__LINE__, [](std::ostream& os) { os << std::setfill('.') << std::right << std::setw(5); }}, os << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::left << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::right << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::setfill('.') << std::left << std::setw(5);
}},
{__LINE__,
[](std::ostream& os) {
os << std::setfill('.') << std::right << std::setw(5);
}},
}; };
for (const auto& testCase : testCases) { for (const auto& testCase : testCases) {
const std::string location = std::string(" at line:") + std::to_string(testCase.line); const std::string location = std::string(" at line:") + std::to_string(testCase.line);
@ -440,8 +457,12 @@ TEST(Ostream, StringDataMatchesStdString) {
std::function<void(std::ostream&)> putter; std::function<void(std::ostream&)> putter;
std::ostringstream os; std::ostringstream os;
}; };
Experiment expected{[&](std::ostream& os) { os << s; }}; Experiment expected{[&](std::ostream& os) {
Experiment actual{[&](std::ostream& os) { os << StringData(s); }}; os << s;
}};
Experiment actual{[&](std::ostream& os) {
os << StringData(s);
}};
for (auto& x : {&expected, &actual}) { for (auto& x : {&expected, &actual}) {
x->os << ">>"; x->os << ">>";
testCase.manip(x->os); testCase.manip(x->os);

View File

@ -260,7 +260,9 @@ BSONColumn::Iterator& BSONColumn::Iterator::operator++() {
++_index; ++_index;
visit(OverloadedVisitor{[&](Regular& regular) { _incrementRegular(regular); }, visit(OverloadedVisitor{[&](Regular& regular) { _incrementRegular(regular); },
[&](Interleaved& interleaved) { _incrementInterleaved(interleaved); }}, [&](Interleaved& interleaved) {
_incrementInterleaved(interleaved);
}},
_mode); _mode);
return *this; return *this;

View File

@ -1196,11 +1196,12 @@ typename BSONColumnBuilder<Allocator>::BinaryDiff BSONColumnBuilder<Allocator>::
// Save some state related to last control byte so we can see how it changes after finalize() is // Save some state related to last control byte so we can see how it changes after finalize() is
// called. // called.
ptrdiff_t controlOffset = ptrdiff_t controlOffset =
visit(OverloadedVisitor{ visit(OverloadedVisitor{[](const typename InternalState::Regular& regular) {
[](const typename InternalState::Regular& regular) { return regular._controlByteOffset;
return regular._controlByteOffset; },
}, [](const typename InternalState::Interleaved&) {
[](const typename InternalState::Interleaved&) { return kNoSimple8bControl; }}, return kNoSimple8bControl;
}},
_is.state); _is.state);
uint8_t lastControlByte = uint8_t lastControlByte =
controlOffset != kNoSimple8bControl ? *(_bufBuilder.buf() + controlOffset) : 0; controlOffset != kNoSimple8bControl ? *(_bufBuilder.buf() + controlOffset) : 0;
@ -1347,7 +1348,9 @@ BSONElement BSONColumnBuilder<Allocator>::last() const {
*regular._prev.data() == stdx::to_underlying(BSONType::eoo) ? 0 : 1, *regular._prev.data() == stdx::to_underlying(BSONType::eoo) ? 0 : 1,
BSONElement::TrustedInitTag{}}; BSONElement::TrustedInitTag{}};
}, },
[](const typename InternalState::Interleaved&) { return BSONElement{}; }}, [](const typename InternalState::Interleaved&) {
return BSONElement{};
}},
_is.state); _is.state);
} }

View File

@ -427,7 +427,7 @@ Simple8bBuilder<T, Allocator>::PendingValue::PendingValue(
boost::optional<T> val, boost::optional<T> val,
std::array<uint8_t, kNumOfSelectorTypes> bitCount, std::array<uint8_t, kNumOfSelectorTypes> bitCount,
std::array<uint8_t, kNumOfSelectorTypes> trailingZerosCount) std::array<uint8_t, kNumOfSelectorTypes> trailingZerosCount)
: val(val), bitCount(bitCount), trailingZerosCount(trailingZerosCount) {}; : val(val), bitCount(bitCount), trailingZerosCount(trailingZerosCount){};
template <typename T, class Allocator> template <typename T, class Allocator>
Simple8bBuilder<T, Allocator>::PendingIterator::PendingIterator( Simple8bBuilder<T, Allocator>::PendingIterator::PendingIterator(

View File

@ -549,8 +549,8 @@ public:
RetryBudget& budget, RetryBudget& budget,
RetryCriteria retryCriteria = defaultRetryCriteria, RetryCriteria retryCriteria = defaultRetryCriteria,
RetryParameters parameters = DefaultRetryStrategy::getRetryParametersFromServerParameters()) RetryParameters parameters = DefaultRetryStrategy::getRetryParametersFromServerParameters())
: _underlyingStrategy{ : _underlyingStrategy{std::make_unique<DefaultRetryStrategy>(std::move(retryCriteria),
std::make_unique<DefaultRetryStrategy>(std::move(retryCriteria), parameters)}, parameters)},
_budget{&budget} {} _budget{&budget} {}
/** /**

View File

@ -43,8 +43,9 @@ const auto getIngressAdmissionController =
ServiceContext::declareDecoration<IngressAdmissionController>(); ServiceContext::declareDecoration<IngressAdmissionController>();
const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{ const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{
"InitIngressAdmissionController", "InitIngressAdmissionController", [](ServiceContext* ctx) {
[](ServiceContext* ctx) { getIngressAdmissionController(ctx).init(); }}; getIngressAdmissionController(ctx).init();
}};
} // namespace } // namespace
void IngressAdmissionController::init() { void IngressAdmissionController::init() {

View File

@ -56,8 +56,9 @@ const auto getIngressRequestRateLimiter =
ServiceContext::declareDecoration<boost::optional<IngressRequestRateLimiter>>(); ServiceContext::declareDecoration<boost::optional<IngressRequestRateLimiter>>();
const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{ const ConstructorActionRegistererType<ServiceContext> onServiceContextCreate{
"InitIngressRequestRateLimiter", "InitIngressRequestRateLimiter", [](ServiceContext* ctx) {
[](ServiceContext* ctx) { getIngressRequestRateLimiter(ctx).emplace(); }}; getIngressRequestRateLimiter(ctx).emplace();
}};
class ClientAdmissionControlState { class ClientAdmissionControlState {
public: public:

View File

@ -49,8 +49,9 @@ void rotateAuditLog() {}
namespace { namespace {
const auto getAuditInterface = ServiceContext::declareDecoration<std::unique_ptr<AuditInterface>>(); const auto getAuditInterface = ServiceContext::declareDecoration<std::unique_ptr<AuditInterface>>();
ServiceContext::ConstructorActionRegisterer registerCreateNoopAudit{ ServiceContext::ConstructorActionRegisterer registerCreateNoopAudit{
"initializeNoopAuditInterface", "initializeNoopAuditInterface", [](ServiceContext* svcCtx) {
[](ServiceContext* svcCtx) { AuditInterface::set(svcCtx, std::make_unique<AuditNoOp>()); }}; AuditInterface::set(svcCtx, std::make_unique<AuditNoOp>());
}};
} // namespace } // namespace
AuditInterface* AuditInterface::get(ServiceContext* service) { AuditInterface* AuditInterface::get(ServiceContext* service) {

View File

@ -433,8 +433,9 @@ std::unique_ptr<DbCheckRun> singleCollectionRun(OperationContext* opCtx,
maxBatchTimeMillis, maxBatchTimeMillis,
_getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()), _getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()),
secondaryIndexCheckParameters, secondaryIndexCheckParameters,
{opCtx->fastClockSource().now().toMillisSinceEpoch(), {opCtx->fastClockSource().now().toMillisSinceEpoch(), [&]() {
[&]() { return gMaxDbCheckMBperSec.load(); }}}; return gMaxDbCheckMBperSec.load();
}}};
auto result = std::make_unique<DbCheckRun>(); auto result = std::make_unique<DbCheckRun>();
result->push_back(info); result->push_back(info);
return result; return result;
@ -471,8 +472,9 @@ std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx,
maxBatchTimeMillis, maxBatchTimeMillis,
_getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()), _getBatchWriteConcern(opCtx, invocation.getBatchWriteConcern()),
boost::none, boost::none,
{opCtx->fastClockSource().now().toMillisSinceEpoch(), {opCtx->fastClockSource().now().toMillisSinceEpoch(), [&]() {
[&]() { return gMaxDbCheckMBperSec.load(); }}}; return gMaxDbCheckMBperSec.load();
}}};
result->push_back(info); result->push_back(info);
return true; return true;
}; };

View File

@ -121,7 +121,9 @@ struct MakeObjSpec {
[](SetArg) { return Type::kSetArg; }, [](SetArg) { return Type::kSetArg; },
[](AddArg) { return Type::kAddArg; }, [](AddArg) { return Type::kAddArg; },
[](LambdaArg) { return Type::kLambdaArg; }, [](LambdaArg) { return Type::kLambdaArg; },
[](const MakeObj&) { return Type::kMakeObj; }}, [](const MakeObj&) {
return Type::kMakeObj;
}},
_data); _data);
} }

View File

@ -467,7 +467,7 @@ IndexScanStageBaseImpl<Derived>::IndexScanStageBaseImpl(
vars, vars,
yieldPolicy, yieldPolicy,
nodeId, nodeId,
participateInTrialRunTracking) {}; participateInTrialRunTracking){};
SimpleIndexScanStage::SimpleIndexScanStage(UUID collUuid, SimpleIndexScanStage::SimpleIndexScanStage(UUID collUuid,
DatabaseName dbName, DatabaseName dbName,

View File

@ -455,7 +455,7 @@ ScanStageBaseImpl<Derived>::ScanStageBaseImpl(UUID collUuid,
scanOpenCallback, scanOpenCallback,
forward, forward,
// Optional arguments: // Optional arguments:
participateInTrialRunTracking) {}; participateInTrialRunTracking){};
template <typename Derived> template <typename Derived>
@ -463,7 +463,7 @@ ScanStageBaseImpl<Derived>::ScanStageBaseImpl(std::shared_ptr<ScanStageBaseState
PlanYieldPolicySBE* yieldPolicy, PlanYieldPolicySBE* yieldPolicy,
PlanNodeId nodeId, PlanNodeId nodeId,
bool participateInTrialRunTracking) bool participateInTrialRunTracking)
: ScanStageBase(std::move(state), yieldPolicy, nodeId, participateInTrialRunTracking) {}; : ScanStageBase(std::move(state), yieldPolicy, nodeId, participateInTrialRunTracking){};
ScanStage::ScanStage(UUID collUuid, ScanStage::ScanStage(UUID collUuid,
DatabaseName dbName, DatabaseName dbName,

View File

@ -36,7 +36,9 @@ namespace {
VersionedExtension makeTestVersionedExtension(uint32_t major, uint32_t minor) { VersionedExtension makeTestVersionedExtension(uint32_t major, uint32_t minor) {
return VersionedExtension{::MongoExtensionAPIVersion{major, minor}, return VersionedExtension{::MongoExtensionAPIVersion{major, minor},
[]() -> std::unique_ptr<sdk::Extension> { return nullptr; }}; []() -> std::unique_ptr<sdk::Extension> {
return nullptr;
}};
} }
class VersionedExtensionGreaterComparatorTest : public unittest::Test { class VersionedExtensionGreaterComparatorTest : public unittest::Test {

View File

@ -114,7 +114,7 @@ boost::filesystem::path getFTDCDirectoryPathParameter() {
} }
Status onUpdateFTDCEnabled(const bool value) { Status onUpdateFTDCEnabled(const bool value) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setEnabled(value); return controller->setEnabled(value);
} }
@ -123,7 +123,7 @@ Status onUpdateFTDCEnabled(const bool value) {
} }
Status onUpdateFTDCMetadataCaptureFrequency(const std::int32_t potentialNewValue) { Status onUpdateFTDCMetadataCaptureFrequency(const std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMetadataCaptureFrequency(potentialNewValue); controller->setMetadataCaptureFrequency(potentialNewValue);
} }
@ -132,7 +132,7 @@ Status onUpdateFTDCMetadataCaptureFrequency(const std::int32_t potentialNewValue
} }
Status onUpdateFTDCPeriod(const std::int32_t potentialNewValue) { Status onUpdateFTDCPeriod(const std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setPeriod(Milliseconds(potentialNewValue)); controller->setPeriod(Milliseconds(potentialNewValue));
FTDCCollectionMetrics::get(getGlobalServiceContext()) FTDCCollectionMetrics::get(getGlobalServiceContext())
@ -152,7 +152,7 @@ Status onUpdateFTDCDirectorySize(const std::int32_t potentialNewValue) {
<< "' which is the current value of diagnosticDataCollectionFileSizeMB."); << "' which is the current value of diagnosticDataCollectionFileSizeMB.");
} }
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxDirectorySizeBytes(potentialNewValue * 1024 * 1024); controller->setMaxDirectorySizeBytes(potentialNewValue * 1024 * 1024);
} }
@ -170,7 +170,7 @@ Status onUpdateFTDCFileSize(const std::int32_t potentialNewValue) {
<< "' which is the current value of diagnosticDataCollectionDirectorySizeMB."); << "' which is the current value of diagnosticDataCollectionDirectorySizeMB.");
} }
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxFileSizeBytes(potentialNewValue * 1024 * 1024); controller->setMaxFileSizeBytes(potentialNewValue * 1024 * 1024);
} }
@ -179,7 +179,7 @@ Status onUpdateFTDCFileSize(const std::int32_t potentialNewValue) {
} }
Status onUpdateFTDCSamplesPerChunk(const std::int32_t potentialNewValue) { Status onUpdateFTDCSamplesPerChunk(const std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxSamplesPerArchiveMetricChunk(potentialNewValue); controller->setMaxSamplesPerArchiveMetricChunk(potentialNewValue);
} }
@ -188,7 +188,7 @@ Status onUpdateFTDCSamplesPerChunk(const std::int32_t potentialNewValue) {
} }
Status onUpdateFTDCPerInterimUpdate(const std::int32_t potentialNewValue) { Status onUpdateFTDCPerInterimUpdate(const std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->setMaxSamplesPerInterimMetricChunk(potentialNewValue); controller->setMaxSamplesPerInterimMetricChunk(potentialNewValue);
} }
@ -197,7 +197,7 @@ Status onUpdateFTDCPerInterimUpdate(const std::int32_t potentialNewValue) {
} }
Status onUpdateFTDCSampleTimeout(std::int32_t potentialNewValue) { Status onUpdateFTDCSampleTimeout(std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setSampleTimeout(Milliseconds(potentialNewValue)); return controller->setSampleTimeout(Milliseconds(potentialNewValue));
} }
@ -206,7 +206,7 @@ Status onUpdateFTDCSampleTimeout(std::int32_t potentialNewValue) {
} }
Status onUpdateFTDCMinThreads(std::int32_t potentialNewValue) { Status onUpdateFTDCMinThreads(std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setMinThreads(potentialNewValue); return controller->setMinThreads(potentialNewValue);
} }
@ -215,7 +215,7 @@ Status onUpdateFTDCMinThreads(std::int32_t potentialNewValue) {
} }
Status onUpdateFTDCMaxThreads(std::int32_t potentialNewValue) { Status onUpdateFTDCMaxThreads(std::int32_t potentialNewValue) {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
return controller->setMaxThreads(potentialNewValue); return controller->setMaxThreads(potentialNewValue);
} }
@ -471,7 +471,7 @@ void startFTDC(ServiceContext* serviceContext,
} }
void stopFTDC() { void stopFTDC() {
if (FTDCController* controller; if (FTDCController * controller;
hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) { hasGlobalServiceContext() && (controller = getFTDCController(getGlobalServiceContext()))) {
controller->stop(); controller->stop();
} }

View File

@ -127,7 +127,9 @@ public:
*/ */
void waitForOngoingCoordinatorsToFinish(OperationContext* opCtx, void waitForOngoingCoordinatorsToFinish(OperationContext* opCtx,
std::function<bool(const ShardingCoordinator&)> pred = { std::function<bool(const ShardingCoordinator&)> pred = {
[](const ShardingCoordinator&) { return true; }}); [](const ShardingCoordinator&) {
return true;
}});
void waitForRecovery(OperationContext* opCtx) const override; void waitForRecovery(OperationContext* opCtx) const override;

View File

@ -84,10 +84,14 @@ private:
}}}, }}},
{"server", {"server",
{BSON(ChangeLogType::server() << _kServer), {BSON(ChangeLogType::server() << _kServer),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getServer(), _kServer); }}}, [&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getServer(), _kServer);
}}},
{"shard", {"shard",
{BSON(ChangeLogType::shard() << _kShard), {BSON(ChangeLogType::shard() << _kShard),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getShard(), _kShard); }}}, [&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getShard(), _kShard);
}}},
{"clientAddr", {"clientAddr",
{BSON(ChangeLogType::clientAddr() << _kClientAddr), {BSON(ChangeLogType::clientAddr() << _kClientAddr),
[&](const ChangeLogType& changelog) { [&](const ChangeLogType& changelog) {
@ -95,10 +99,14 @@ private:
}}}, }}},
{"time", {"time",
{BSON(ChangeLogType::time() << _kTime), {BSON(ChangeLogType::time() << _kTime),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getTime(), _kTime); }}}, [&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getTime(), _kTime);
}}},
{"what", {"what",
{BSON(ChangeLogType::what() << _kWhat), {BSON(ChangeLogType::what() << _kWhat),
[&](const ChangeLogType& changelog) { ASSERT_EQUALS(changelog.getWhat(), _kWhat); }}}, [&](const ChangeLogType& changelog) {
ASSERT_EQUALS(changelog.getWhat(), _kWhat);
}}},
{"versionContext", {"versionContext",
{BSON(ChangeLogType::versionContext() << _kVersionContext.toBSON()), {BSON(ChangeLogType::versionContext() << _kVersionContext.toBSON()),
[&](const ChangeLogType& changelog) { [&](const ChangeLogType& changelog) {

View File

@ -408,7 +408,8 @@ TEST_F(IndexAccessMethodBulkBuilder, CommitRejectsZeroInterval) {
}}, }},
IndexAccessMethod::RecordIdHandlerFn{}, IndexAccessMethod::RecordIdHandlerFn{},
IndexAccessMethod::YieldFn{}, IndexAccessMethod::YieldFn{},
IndexAccessMethod::OnNKeysLoadedFn{[]() {}}, IndexAccessMethod::OnNKeysLoadedFn{[]() {
}},
/*onNKeysLoadedFnInterval=*/0, /*onNKeysLoadedFnInterval=*/0,
/*keyBatchSize=*/1, /*keyBatchSize=*/1,
/*keyBatchBytes=*/1024), /*keyBatchBytes=*/1024),

View File

@ -351,7 +351,9 @@ struct ValidationErrorContext {
verifySizeAndAppend(details, kDetailsString, builder); verifySizeAndAppend(details, kDetailsString, builder);
}, },
[&](const std::monostate& state) -> void { MONGO_UNREACHABLE }, [&](const std::monostate& state) -> void { MONGO_UNREACHABLE },
[&](const std::string& str) -> void { MONGO_UNREACHABLE }}, [&](const std::string& str) -> void {
MONGO_UNREACHABLE
}},
latestCompleteError); latestCompleteError);
} }
/** /**
@ -372,7 +374,9 @@ struct ValidationErrorContext {
verifySizeAndAppend(elem, builder); verifySizeAndAppend(elem, builder);
} }
}, },
[&](const std::monostate& state) -> void { MONGO_UNREACHABLE }}, [&](const std::monostate& state) -> void {
MONGO_UNREACHABLE
}},
latestCompleteError); latestCompleteError);
} }

View File

@ -215,9 +215,10 @@ void buildUpdateDescriptionWithDeltaOplog(
while (auto nextSubDiff = reader->nextSubDiff()) { while (auto nextSubDiff = reader->nextSubDiff()) {
std::variant<DocumentDiffReader*, ArrayDiffReader*> nextReader; std::variant<DocumentDiffReader*, ArrayDiffReader*> nextReader;
visit( visit(OverloadedVisitor{[&nextReader](auto& reader) {
OverloadedVisitor{[&nextReader](auto& reader) { nextReader = &reader; }}, nextReader = &reader;
nextSubDiff->second); }},
nextSubDiff->second);
buildUpdateDescriptionWithDeltaOplog( buildUpdateDescriptionWithDeltaOplog(
nextReader, builder, {{nextSubDiff->first}}); nextReader, builder, {{nextSubDiff->first}});
} }

View File

@ -84,7 +84,9 @@ public:
*/ */
Value toValue() const { Value toValue() const {
return visit(OverloadedVisitor{[&](Value unwrappedVal) { return unwrappedVal; }, return visit(OverloadedVisitor{[&](Value unwrappedVal) { return unwrappedVal; },
[&](Date_t dateVal) { return Value(dateVal); } [&](Date_t dateVal) {
return Value(dateVal);
}
}, },
_value); _value);
@ -128,7 +130,9 @@ public:
std::string toString() const { std::string toString() const {
return visit(OverloadedVisitor{[&](Value v) { return v.toString(); }, return visit(OverloadedVisitor{[&](Value v) { return v.toString(); },
[&](Date_t d) { return d.toString(); }}, [&](Date_t d) {
return d.toString();
}},
_value); _value);
} }
@ -147,7 +151,9 @@ public:
*/ */
size_t getApproximateSize() const { size_t getApproximateSize() const {
return visit(OverloadedVisitor{[&](Value v) { return v.getApproximateSize(); }, return visit(OverloadedVisitor{[&](Value v) { return v.getApproximateSize(); },
[&](Date_t d) { return Value(d).getApproximateSize(); }}, [&](Date_t d) {
return Value(d).getApproximateSize();
}},
_value); _value);
} }

View File

@ -102,8 +102,9 @@ public:
OwningDistributedPlanContext(std::unique_ptr<Pipeline> pipelinePrefix, OwningDistributedPlanContext(std::unique_ptr<Pipeline> pipelinePrefix,
std::unique_ptr<Pipeline> pipelineSuffix, std::unique_ptr<Pipeline> pipelineSuffix,
boost::optional<OrderedPathSet> shardKeys) boost::optional<OrderedPathSet> shardKeys)
: DocumentSourceGroup::DistributedPlanContext{ : DocumentSourceGroup::DistributedPlanContext{*pipelinePrefix,
*pipelinePrefix, *pipelineSuffix, this->shardKeys}, *pipelineSuffix,
this->shardKeys},
pipelinePrefix(std::move(pipelinePrefix)), pipelinePrefix(std::move(pipelinePrefix)),
pipelineSuffix(std::move(pipelineSuffix)), pipelineSuffix(std::move(pipelineSuffix)),
shardKeys(std::move(shardKeys)) {} shardKeys(std::move(shardKeys)) {}

View File

@ -1372,8 +1372,9 @@ private:
boost::optional<query_settings::QuerySettings> _querySettings = boost::none; boost::optional<query_settings::QuerySettings> _querySettings = boost::none;
DeferredFn<QueryKnobConfiguration, const query_settings::QuerySettings&> DeferredFn<QueryKnobConfiguration, const query_settings::QuerySettings&>
_queryKnobConfiguration{ _queryKnobConfiguration{[](const auto& querySettings) {
[](const auto& querySettings) { return QueryKnobConfiguration(querySettings); }}; return QueryKnobConfiguration(querySettings);
}};
Deferred<bool (*)(const VersionContext&)> _featureFlagShardFilteringDistinctScan{ Deferred<bool (*)(const VersionContext&)> _featureFlagShardFilteringDistinctScan{
[](const VersionContext& vCtx) { [](const VersionContext& vCtx) {

View File

@ -1824,21 +1824,23 @@ std::unique_ptr<Pipeline> targetShardsAndAddMergeCursors(
bool useCollectionDefaultCollator) { bool useCollectionDefaultCollator) {
auto&& aggRequestPipelinePair = [&] { auto&& aggRequestPipelinePair = [&] {
return visit( return visit(
OverloadedVisitor{ OverloadedVisitor{[&](std::unique_ptr<Pipeline>&& pipeline) {
[&](std::unique_ptr<Pipeline>&& pipeline) { return std::make_pair(
return std::make_pair(AggregateCommandRequest(expCtx->getNamespaceString(), AggregateCommandRequest(expCtx->getNamespaceString(),
pipeline->serializeToBson()), pipeline->serializeToBson()),
std::move(pipeline)); std::move(pipeline));
}, },
[&](AggregateCommandRequest&& aggRequest) { [&](AggregateCommandRequest&& aggRequest) {
auto rawPipeline = aggRequest.getPipeline(); auto rawPipeline = aggRequest.getPipeline();
return std::make_pair( return std::make_pair(
std::move(aggRequest), std::move(aggRequest),
pipeline_factory::makePipeline( pipeline_factory::makePipeline(
rawPipeline, expCtx, pipeline_factory::kOptionsMinimal)); rawPipeline, expCtx, pipeline_factory::kOptionsMinimal));
}, },
[&](std::pair<AggregateCommandRequest, std::unique_ptr<Pipeline>>&& [&](std::pair<AggregateCommandRequest, std::unique_ptr<Pipeline>>&&
aggRequestPipelinePair) { return std::move(aggRequestPipelinePair); }}, aggRequestPipelinePair) {
return std::move(aggRequestPipelinePair);
}},
std::move(targetRequest)); std::move(targetRequest));
}(); }();
const auto& aggRequest = aggRequestPipelinePair.first; const auto& aggRequest = aggRequestPipelinePair.first;

View File

@ -76,8 +76,9 @@ using StageParamsToDocumentSourceFn = std::function<std::list<boost::intrusive_p
* REGISTER_STAGE_PARAMS_TO_DOCUMENT_SOURCE_MAPPING macro defined in this file. * REGISTER_STAGE_PARAMS_TO_DOCUMENT_SOURCE_MAPPING macro defined in this file.
*/ */
MONGO_MOD_PUBLIC // Needed by enterprise hot backup registrations. MONGO_MOD_PUBLIC // Needed by enterprise hot backup registrations.
void registerStageParamsToDocumentSourceFn(StageParams::Id stageParamsId, void
StageParamsToDocumentSourceFn fn); registerStageParamsToDocumentSourceFn(StageParams::Id stageParamsId,
StageParamsToDocumentSourceFn fn);
/** /**
* Create the corresponding 'DocumentSource' object for the given instance of * Create the corresponding 'DocumentSource' object for the given instance of

View File

@ -380,8 +380,9 @@ void visitExtensionStage(DocsNeededBoundsContext* ctx,
} }
const ServiceContext::ConstructorActionRegisterer docsNeededBoundsRegisterer{ const ServiceContext::ConstructorActionRegisterer docsNeededBoundsRegisterer{
"DocsNeededBoundsRegisterer", "DocsNeededBoundsRegisterer", [](ServiceContext* service) {
[](ServiceContext* service) { registerMongodVisitor<DocsNeededBoundsContext>(service); }}; registerMongodVisitor<DocsNeededBoundsContext>(service);
}};
DocsNeededBounds extractDocsNeededBounds(const DocumentSourceContainer& sources, DocsNeededBounds extractDocsNeededBounds(const DocumentSourceContainer& sources,

View File

@ -223,10 +223,12 @@ void doProfile(auto opCtx,
boost::optional<CollectionAcquisition> profileCollection; boost::optional<CollectionAcquisition> profileCollection;
while (true) { while (true) {
const auto deadline = std::visit( const auto deadline =
OverloadedVisitor{[&](const NoTimeoutTag&) { return Date_t::max(); }, std::visit(OverloadedVisitor{[&](const NoTimeoutTag&) { return Date_t::max(); },
[&](const Milliseconds& millis) { return Date_t::now() + millis; }}, [&](const Milliseconds& millis) {
lockTimeout); return Date_t::now() + millis;
}},
lockTimeout);
profileCollection.emplace(acquireCollection( profileCollection.emplace(acquireCollection(
newCtx.get(), newCtx.get(),

View File

@ -158,17 +158,19 @@ BSONObj JoinPlanNodeRegistry::joinPlanNodeToBSON(JoinPlanNodeId nodeId,
bob << "cost" << getCost(nodeId).toBSON(); bob << "cost" << getCost(nodeId).toBSON();
} }
std::visit( std::visit(
OverloadedVisitor{ OverloadedVisitor{[this, numNodesToPrint, &bob](const JoiningNode& join) {
[this, numNodesToPrint, &bob](const JoiningNode& join) { bob << "method" << joinMethodToString(join.method);
bob << "method" << joinMethodToString(join.method); bob << "left" << joinPlanNodeToBSON(join.left, numNodesToPrint);
bob << "left" << joinPlanNodeToBSON(join.left, numNodesToPrint); bob << "right" << joinPlanNodeToBSON(join.right, numNodesToPrint);
bob << "right" << joinPlanNodeToBSON(join.right, numNodesToPrint); },
}, [&bob](const INLJRHSNode& ip) {
[&bob](const INLJRHSNode& ip) { bob << "accessPath"
bob << "accessPath" << (str::stream()
<< (str::stream() << "INDEX_PROBE " << ip.entry->descriptor()->keyPattern()); << "INDEX_PROBE " << ip.entry->descriptor()->keyPattern());
}, },
[&bob](const BaseNode& base) { bob << "accessPath" << base.soln->summaryString(); }}, [&bob](const BaseNode& base) {
bob << "accessPath" << base.soln->summaryString();
}},
get(nodeId)); get(nodeId));
return bob.obj(); return bob.obj();
} }

View File

@ -163,7 +163,9 @@ inline JoinCostEstimate getNodeCost(const JoinPlanNode& node) {
MONGO_UNREACHABLE_TASSERT(11727800); MONGO_UNREACHABLE_TASSERT(11727800);
return JoinCostEstimate(zeroCE, zeroCE, zeroCE, zeroCE); return JoinCostEstimate(zeroCE, zeroCE, zeroCE, zeroCE);
}, },
[](const BaseNode& base) { return base.cost; }}, [](const BaseNode& base) {
return base.cost;
}},
node); node);
} }
@ -174,7 +176,9 @@ inline NodeSet getNodeBitset(const JoinPlanNode& node) {
return std::visit( return std::visit(
OverloadedVisitor{[](const JoiningNode& join) { return join.bitset; }, OverloadedVisitor{[](const JoiningNode& join) { return join.bitset; },
[](const INLJRHSNode& ip) { return NodeSet().set(ip.node); }, [](const INLJRHSNode& ip) { return NodeSet().set(ip.node); },
[](const BaseNode& base) { return NodeSet().set(base.node); }}, [](const BaseNode& base) {
return NodeSet().set(base.node);
}},
node); node);
} }

View File

@ -83,7 +83,9 @@ using BSONValue = std::variant<BSONElement, std::reference_wrapper<Value>>;
template <typename T> template <typename T>
T parseFindPayload(BSONValue payload) { T parseFindPayload(BSONValue payload) {
return visit(OverloadedVisitor{[&](BSONElement payload) { return T(payload); }, return visit(OverloadedVisitor{[&](BSONElement payload) { return T(payload); },
[&](Value payload) { return T(payload); }}, [&](Value payload) {
return T(payload);
}},
payload); payload);
} }

View File

@ -975,9 +975,12 @@ public:
CanonicalQuery* cq, CanonicalQuery* cq,
PlanYieldPolicy::YieldPolicy policy, PlanYieldPolicy::YieldPolicy policy,
std::unique_ptr<QueryPlannerParams> plannerParams) std::unique_ptr<QueryPlannerParams> plannerParams)
: SbeWithClassicRuntimePlanningPrepareExecutionHelperBase{ : SbeWithClassicRuntimePlanningPrepareExecutionHelperBase{opCtx,
opCtx, collections, cq, policy, std::move(plannerParams), false /*useSbePlanCache*/} { collections,
} cq,
policy,
std::move(plannerParams),
false /*useSbePlanCache*/} {}
private: private:
PlanCacheKey buildPlanCacheKey() const override { PlanCacheKey buildPlanCacheKey() const override {

View File

@ -52,7 +52,7 @@ public:
// Allow implicit construction from a string literal, but not from a const char*. // Allow implicit construction from a string literal, but not from a const char*.
template <size_t N> template <size_t N>
StrongStringAlias(const char (&value)[N]) : _value(value) {}; StrongStringAlias(const char (&value)[N]) : _value(value){};
// We disallow empty strings based on the tag's kAllowEmpty field. // We disallow empty strings based on the tag's kAllowEmpty field.
template <class TagType1 = TagType, class = typename std::enable_if_t<!TagType1::kAllowEmpty>> template <class TagType1 = TagType, class = typename std::enable_if_t<!TagType1::kAllowEmpty>>

View File

@ -747,8 +747,9 @@ boost::optional<SbBlockAggExprVector> tryToGenerateOneBlockAccumulator(
* exit. * exit.
*/ */
auto makeValueGuard(auto* dst, auto val) { auto makeValueGuard(auto* dst, auto val) {
return ScopeGuard{ return ScopeGuard{[dst, old = std::exchange(*dst, std::move(val))]() mutable {
[dst, old = std::exchange(*dst, std::move(val))]() mutable { *dst = std::move(old); }}; *dst = std::move(old);
}};
} }
SbHashAggAccumulatorVector generateScalarAccumulators(StageBuilderState& state, SbHashAggAccumulatorVector generateScalarAccumulators(StageBuilderState& state,

View File

@ -751,7 +751,9 @@ public:
}, },
[](const Expr& e) { return ProjectNode(e.expr); }, [](const Expr& e) { return ProjectNode(e.expr); },
[](const SbExpr& e) { return ProjectNode(e.clone()); }, [](const SbExpr& e) { return ProjectNode(e.clone()); },
[](const Slice& s) { return ProjectNode(s); }}, [](const Slice& s) {
return ProjectNode(s);
}},
_data); _data);
} }
@ -759,7 +761,9 @@ public:
return visit(OverloadedVisitor{[](const Bool&) { return Type::kBool; }, return visit(OverloadedVisitor{[](const Bool&) { return Type::kBool; },
[](const Expr&) { return Type::kExpr; }, [](const Expr&) { return Type::kExpr; },
[](const SbExpr&) { return Type::kSbExpr; }, [](const SbExpr&) { return Type::kSbExpr; },
[](const Slice&) { return Type::kSlice; }}, [](const Slice&) {
return Type::kSlice;
}},
_data); _data);
} }

View File

@ -59,7 +59,9 @@ ProjectActionType ProjectAction::type() const {
[](const SetArg&) { return ProjectActionType::kSetArg; }, [](const SetArg&) { return ProjectActionType::kSetArg; },
[](const AddArg&) { return ProjectActionType::kAddArg; }, [](const AddArg&) { return ProjectActionType::kAddArg; },
[](const LambdaArg&) { return ProjectActionType::kLambdaArg; }, [](const LambdaArg&) { return ProjectActionType::kLambdaArg; },
[](const MakeObj&) { return ProjectActionType::kMakeObj; }}, [](const MakeObj&) {
return ProjectActionType::kMakeObj;
}},
_data); _data);
} }

View File

@ -340,9 +340,7 @@ TEST_F(LookupStageBuilderTest, NestedLoopJoin_TopLevelLocalField_Null) {
std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected{ std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected{
{ldocs[0], {ldocs[0],
{fdocs[1], {fdocs[1], fdocs[2], fdocs[3],
fdocs[2],
fdocs[3],
/*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}}, /*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}},
}; };
@ -364,9 +362,7 @@ TEST_F(LookupStageBuilderTest, NestedLoopJoin_TopLevelLocalField_Missing) {
std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected = { std::vector<std::pair<BSONObj, std::vector<BSONObj>>> expected = {
{ldocs[0], {ldocs[0],
{fdocs[1], {fdocs[1], fdocs[2], fdocs[3],
fdocs[2],
fdocs[3],
/*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}}, /*fdocs[4], fdocs[5] - match in classic, but for undefined we don't care*/}},
}; };

View File

@ -105,7 +105,9 @@ TEST(DeferredTest, DeferredInitializationWithOneArgument) {
} }
TEST(DeferredTest, DeferredInitializationWithTwoArgs) { TEST(DeferredTest, DeferredInitializationWithTwoArgs) {
Deferred deferred{[&](const string& input, const string& prefix) { return prefix + input; }}; Deferred deferred{[&](const string& input, const string& prefix) {
return prefix + input;
}};
ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s); ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s);
ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s); ASSERT_EQ(deferred.get("cowbell", "more "), "more cowbell"s);

View File

@ -777,7 +777,9 @@ int UpdateModification::objsize() const {
return size + kWriteCommandBSONArrayPerElementOverheadBytes; return size + kWriteCommandBSONArrayPerElementOverheadBytes;
}, },
[](const DeltaUpdate& delta) -> int { return delta.diff.objsize(); }, [](const DeltaUpdate& delta) -> int { return delta.diff.objsize(); },
[](const TransformUpdate& transform) -> int { return 0; }}, [](const TransformUpdate& transform) -> int {
return 0;
}},
_update); _update);
} }
@ -787,7 +789,9 @@ UpdateModification::Type UpdateModification::type() const {
[](const ModifierUpdate& modifier) { return Type::kModifier; }, [](const ModifierUpdate& modifier) { return Type::kModifier; },
[](const PipelineUpdate& pipelineUpdate) { return Type::kPipeline; }, [](const PipelineUpdate& pipelineUpdate) { return Type::kPipeline; },
[](const DeltaUpdate& delta) { return Type::kDelta; }, [](const DeltaUpdate& delta) { return Type::kDelta; },
[](const TransformUpdate& transform) { return Type::kTransform; }}, [](const TransformUpdate& transform) {
return Type::kTransform;
}},
_update); _update);
} }
@ -812,7 +816,8 @@ void UpdateModification::serializeToBSON(StringData fieldName, BSONObjBuilder* b
arrayBuilder.doneFast(); arrayBuilder.doneFast();
}, },
[fieldName, bob](const DeltaUpdate& delta) { *bob << fieldName << delta.diff; }, [fieldName, bob](const DeltaUpdate& delta) { *bob << fieldName << delta.diff; },
[](const TransformUpdate& transform) {}}, [](const TransformUpdate& transform) {
}},
_update); _update);
} }

View File

@ -556,8 +556,9 @@ inline boost::optional<query_shape::DeferredQueryShape> computeInsertQueryShape(
if (wholeOp.getEncryptionInformation()) { if (wholeOp.getEncryptionInformation()) {
return boost::none; return boost::none;
} }
query_shape::DeferredQueryShape deferredShape{ query_shape::DeferredQueryShape deferredShape{[&]() {
[&]() { return shape_helpers::tryMakeShape<query_shape::InsertCmdShape>(wholeOp); }}; return shape_helpers::tryMakeShape<query_shape::InsertCmdShape>(wholeOp);
}};
return deferredShape; return deferredShape;
} }

View File

@ -192,20 +192,22 @@ public:
std::string toString() const { std::string toString() const {
StringBuilder sb; StringBuilder sb;
visit(OverloadedVisitor{ visit(OverloadedVisitor{[&sb](const ReplacementUpdate& replacement) {
[&sb](const ReplacementUpdate& replacement) { sb << "{type: Replacement, update: " << replacement.bson << "}";
sb << "{type: Replacement, update: " << replacement.bson << "}"; },
}, [&sb](const ModifierUpdate& modifier) {
[&sb](const ModifierUpdate& modifier) { sb << "{type: Modifier, update: " << modifier.bson << "}";
sb << "{type: Modifier, update: " << modifier.bson << "}"; },
}, [&sb](const PipelineUpdate& pipeline) {
[&sb](const PipelineUpdate& pipeline) { sb << "{type: Pipeline, update: " << Value(pipeline).toString()
sb << "{type: Pipeline, update: " << Value(pipeline).toString() << "}"; << "}";
}, },
[&sb](const DeltaUpdate& delta) { [&sb](const DeltaUpdate& delta) {
sb << "{type: Delta, update: " << delta.diff << "}"; sb << "{type: Delta, update: " << delta.diff << "}";
}, },
[&sb](const TransformUpdate& transform) { sb << "{type: Transform}"; }}, [&sb](const TransformUpdate& transform) {
sb << "{type: Transform}";
}},
_update); _update);
return sb.str(); return sb.str();

View File

@ -1302,10 +1302,14 @@ const StringMap<ApplyOpMetadata> kOpsMap = {
}}}, }}},
{"commitTransaction", {"commitTransaction",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode) {[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status { return applyCommitTransaction(opCtx, op, mode); }}}, -> Status {
return applyCommitTransaction(opCtx, op, mode);
}}},
{"abortTransaction", {"abortTransaction",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode) {[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status { return applyAbortTransaction(opCtx, op, mode); }}}, -> Status {
return applyAbortTransaction(opCtx, op, mode);
}}},
{"createDatabaseMetadata", {"createDatabaseMetadata",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode) {[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status { -> Status {

View File

@ -528,7 +528,9 @@ TEST_F(OplogApplierImplTest, applyOplogEntryToRecordChangeStreamPreImages) {
auto op = makeOplogEntry( auto op = makeOplogEntry(
[opCtx = _opCtx.get()] { [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(), }(),
testCase.opType, testCase.opType,
@ -603,7 +605,9 @@ TEST_F(OplogApplierImplTest, ApplyApplyOpsWithMixedFromMigrateRecordsCorrectPreI
// Get an optime for the applyOps entry. // Get an optime for the applyOps entry.
auto opTime = [opCtx = _opCtx.get()] { auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
@ -832,7 +836,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenant) {
// createCollection uses an actual opTime, so we must generate an actually opTime in the future. // createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] { auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});
@ -860,7 +866,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantRequireTenantIDFa
// createCollection uses an actual opTime, so we must generate an actually opTime in the future. // createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] { auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});
@ -893,7 +901,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantAcrossTenantsRequ
// createCollection uses an actual opTime, so we must generate an actually opTime in the future. // createCollection uses an actual opTime, so we must generate an actually opTime in the future.
auto opTime = [opCtx = _opCtx.get()] { auto opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {});

View File

@ -421,7 +421,9 @@ TEST_F(DeleteWithRecordIdAndPreImagesTest,
// Create a delete oplog entry with recordId. // Create a delete oplog entry with recordId.
OpTime opTime = [opCtx = _opCtx.get()] { OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeDeleteOplogEntryWithRecordId(opTime, _nss, _uuid, BSON("_id" << 1), rid); auto op = makeDeleteOplogEntryWithRecordId(opTime, _nss, _uuid, BSON("_id" << 1), rid);
@ -461,7 +463,9 @@ DEATH_TEST_F(DeleteWithRecordIdAndPreImagesDeathTest,
// Create an update oplog entry with the non-existent recordId. // Create an update oplog entry with the non-existent recordId.
OpTime opTime = [opCtx = _opCtx.get()] { OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = auto op =

View File

@ -611,7 +611,9 @@ TEST_F(UpdateWithRecordIdAndPreImagesTest,
// Create an update oplog entry with recordId. // Create an update oplog entry with recordId.
OpTime opTime = [opCtx = _opCtx.get()] { OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeUpdateOplogEntryWithRecordId( auto op = makeUpdateOplogEntryWithRecordId(
@ -654,7 +656,9 @@ DEATH_TEST_F(UpdateWithRecordIdAndPreImagesDeathTest,
// Create an update oplog entry with the non-existent recordId. // Create an update oplog entry with the non-existent recordId.
OpTime opTime = [opCtx = _opCtx.get()] { OpTime opTime = [opCtx = _opCtx.get()] {
WriteUnitOfWork wuow{opCtx}; WriteUnitOfWork wuow{opCtx};
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
auto op = makeUpdateOplogEntryWithRecordId( auto op = makeUpdateOplogEntryWithRecordId(

View File

@ -270,8 +270,9 @@ Status RollbackImpl::runRollback(OperationContext* opCtx) {
// the size storer information is no longer accurate. This may be necessary if capped deletes // the size storer information is no longer accurate. This may be necessary if capped deletes
// are rolled-back or if rollback occurs across a collection rename. // are rolled-back or if rollback occurs across a collection rename.
sizeRecovery.setRecordStoresShouldAlwaysCheckSize(true); sizeRecovery.setRecordStoresShouldAlwaysCheckSize(true);
ScopeGuard sizeRecoveryStateGuard{ ScopeGuard sizeRecoveryStateGuard{[&sizeRecovery] {
[&sizeRecovery] { sizeRecovery.setRecordStoresShouldAlwaysCheckSize(false); }}; sizeRecovery.setRecordStoresShouldAlwaysCheckSize(false);
}};
// After successfully transitioning to the ROLLBACK state, we must always transition back to // After successfully transitioning to the ROLLBACK state, we must always transition back to
// SECONDARY, even if we fail at any point during the rollback process. // SECONDARY, even if we fail at any point during the rollback process.

View File

@ -252,7 +252,8 @@ protected:
} }
protected: protected:
AutoMergerPolicy _automerger{[]() {}}; AutoMergerPolicy _automerger{[]() {
}};
inline const static auto _shards = inline const static auto _shards =
std::vector<ShardType>{ShardType{"shard0", "host0:123"}, ShardType{"shard1", "host1:123"}}; std::vector<ShardType>{ShardType{"shard0", "host0:123"}, ShardType{"shard1", "host1:123"}};

View File

@ -171,8 +171,10 @@ TEST_F(BalancerCommandsSchedulerTest, StartAndStopScheduler) {
} }
TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveRangeCommand) { TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveRangeCommand) {
auto remoteResponsesFuture = setRemoteResponses( auto remoteResponsesFuture =
{[&](const executor::RemoteCommandRequest& request) { return OkReply().toBSON(); }}); setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return OkReply().toBSON();
}});
_scheduler.start(operationContext()); _scheduler.start(operationContext());
ShardsvrMoveRange shardsvrRequest(kNss); ShardsvrMoveRange shardsvrRequest(kNss);
shardsvrRequest.setCollectionTimestamp(Timestamp(10)); shardsvrRequest.setCollectionTimestamp(Timestamp(10));
@ -192,8 +194,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveRangeCommand) {
} }
TEST_F(BalancerCommandsSchedulerTest, SuccessfulMergeChunkCommand) { TEST_F(BalancerCommandsSchedulerTest, SuccessfulMergeChunkCommand) {
auto remoteResponsesFuture = setRemoteResponses( auto remoteResponsesFuture =
{[&](const executor::RemoteCommandRequest& request) { return OkReply().toBSON(); }}); setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return OkReply().toBSON();
}});
_scheduler.start(operationContext()); _scheduler.start(operationContext());
ChunkRange range(BSON("x" << 0), BSON("x" << 20)); ChunkRange range(BSON("x" << 0), BSON("x" << 20));
@ -223,8 +227,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulRequestChunkDataSizeCommand) {
chunkSizeResponse.append("ok", "1"); chunkSizeResponse.append("ok", "1");
chunkSizeResponse.append("size", 156); chunkSizeResponse.append("size", 156);
chunkSizeResponse.append("numObjects", 25); chunkSizeResponse.append("numObjects", 25);
auto remoteResponsesFuture = setRemoteResponses( auto remoteResponsesFuture =
{[&](const executor::RemoteCommandRequest& request) { return chunkSizeResponse.obj(); }}); setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return chunkSizeResponse.obj();
}});
_scheduler.start(operationContext()); _scheduler.start(operationContext());
ChunkType chunk = makeChunk(0, kShardId0); ChunkType chunk = makeChunk(0, kShardId0);
@ -295,8 +301,10 @@ TEST_F(BalancerCommandsSchedulerTest, SuccessfulMoveCollectionRequest) {
TEST_F(BalancerCommandsSchedulerTest, CommandFailsWhenNetworkReturnsError) { TEST_F(BalancerCommandsSchedulerTest, CommandFailsWhenNetworkReturnsError) {
auto timeoutError = Status{ErrorCodes::NetworkTimeout, "Mock error: network timed out"}; auto timeoutError = Status{ErrorCodes::NetworkTimeout, "Mock error: network timed out"};
auto remoteResponsesFuture = setRemoteResponses( auto remoteResponsesFuture =
{[&](const executor::RemoteCommandRequest& request) { return timeoutError; }}); setRemoteResponses({[&](const executor::RemoteCommandRequest& request) {
return timeoutError;
}});
_scheduler.start(operationContext()); _scheduler.start(operationContext());
auto req = makeMoveRangeRequest(0, kShardId1, kShardId0); auto req = makeMoveRangeRequest(0, kShardId1, kShardId0);
auto futureResponse = _scheduler.requestMoveRange( auto futureResponse = _scheduler.requestMoveRange(

View File

@ -783,7 +783,9 @@ TEST_F(BalancerDefragmentationPolicyTest, PhaseOneNotConsecutive) {
} }
}, },
[](const MigrateInfo& _) { FAIL("Unexpected action type"); }, [](const MigrateInfo& _) { FAIL("Unexpected action type"); },
[](const MergeAllChunksOnShardInfo& _) { FAIL("Unexpected action type"); }}, [](const MergeAllChunksOnShardInfo& _) {
FAIL("Unexpected action type");
}},
action); action);
}; };
inspectAction(*nextAction); inspectAction(*nextAction);

View File

@ -50,17 +50,19 @@ protected:
} }
PrimaryOnlyServiceRetryStrategy makeStrategy() { PrimaryOnlyServiceRetryStrategy makeStrategy() {
return PrimaryOnlyServiceRetryStrategy{ return PrimaryOnlyServiceRetryStrategy{kDefaultRetryabilityPredicate,
kDefaultRetryabilityPredicate, [this](const Status& s) { ++_transientErrorCount; },
[this](const Status& s) { ++_transientErrorCount; }, [this](const Status& s) {
[this](const Status& s) { ++_unrecoverableErrorCount; }}; ++_unrecoverableErrorCount;
}};
} }
PrimaryOnlyServiceRetryStrategy makeNeverRetryStrategy() { PrimaryOnlyServiceRetryStrategy makeNeverRetryStrategy() {
return PrimaryOnlyServiceRetryStrategy{ return PrimaryOnlyServiceRetryStrategy{makeNeverRetryPredicate(),
makeNeverRetryPredicate(), [this](const Status& s) { ++_transientErrorCount; },
[this](const Status& s) { ++_transientErrorCount; }, [this](const Status& s) {
[this](const Status& s) { ++_unrecoverableErrorCount; }}; ++_unrecoverableErrorCount;
}};
} }
int transientErrorCount() const { int transientErrorCount() const {

View File

@ -117,7 +117,9 @@ public:
auto body = std::make_shared<BodyCallable>(std::move(_body)); auto body = std::make_shared<BodyCallable>(std::move(_body));
return AsyncTry{[body, retryFactory = _retryFactory, executor, cancelToken] { return AsyncTry{[body, retryFactory = _retryFactory, executor, cancelToken] {
auto strategy = retryFactory.make(); auto strategy = retryFactory.make();
return AsyncTry{[body](const TargetingMetadata& metadata) { return (*body)(); }} return AsyncTry{[body](const TargetingMetadata& metadata) {
return (*body)();
}}
.withRetryStrategy(strategy) .withRetryStrategy(strategy)
.on(executor, cancelToken); .on(executor, cancelToken);
}} }}
@ -140,8 +142,9 @@ public:
auto runOn(SleepableExecutor executor, auto runOn(SleepableExecutor executor,
CancellationToken cancelToken, CancellationToken cancelToken,
std::shared_ptr<RetryStrategy> retryStrategy) && { std::shared_ptr<RetryStrategy> retryStrategy) && {
return AsyncTry{ return AsyncTry{[body = std::move(_body)](const TargetingMetadata& metadata) {
[body = std::move(_body)](const TargetingMetadata& metadata) { return body(); }} return body();
}}
.withRetryStrategy(std::move(retryStrategy)) .withRetryStrategy(std::move(retryStrategy))
.on(executor, cancelToken); .on(executor, cancelToken);
} }

View File

@ -276,8 +276,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
shardToNumDocsCopied.emplace(shard2, 200); shardToNumDocsCopied.emplace(shard2, 200);
runPhaseTransitionTest(PhaseTransitionTestCase{ runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying, .initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
.transitionFn = [&]() { _dao->updateNumberOfDocsToCopy(_opCtx, shardToNumDocsCopied); }}); _dao->updateNumberOfDocsToCopy(_opCtx, shardToNumDocsCopied);
}});
} }
TEST_F(ReshardingCoordinatorDaoFixture, UpdateNumberOfDocsCopiedFinal) { TEST_F(ReshardingCoordinatorDaoFixture, UpdateNumberOfDocsCopiedFinal) {
@ -359,8 +360,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
auto applyStartTime = _clock->now(); auto applyStartTime = _clock->now();
runPhaseTransitionTest(PhaseTransitionTestCase{ runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying, .initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
.transitionFn = [&]() { _dao->transitionToApplyingPhase(_opCtx, applyStartTime); }}); _dao->transitionToApplyingPhase(_opCtx, applyStartTime);
}});
} }
TEST_F(ReshardingCoordinatorDaoFixture, TransitionToBlockingWritesPhaseSucceeds) { TEST_F(ReshardingCoordinatorDaoFixture, TransitionToBlockingWritesPhaseSucceeds) {
@ -448,8 +450,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
Status abortReason = Status::OK(); Status abortReason = Status::OK();
runPhaseTransitionTest(PhaseTransitionTestCase{ runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kApplying, .initialPhase = CoordinatorStateEnum::kApplying, .transitionFn = [&]() {
.transitionFn = [&]() { _dao->transitionToAbortingPhase(_opCtx, now, abortReason); }}); _dao->transitionToAbortingPhase(_opCtx, now, abortReason);
}});
} }
DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest, DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
@ -459,8 +462,9 @@ DEATH_TEST_F(ReshardingCoordinatorDaoFixtureDeathTest,
Status abortReason{ErrorCodes::InternalError, "Something went horribly wrong"}; Status abortReason{ErrorCodes::InternalError, "Something went horribly wrong"};
runPhaseTransitionTest(PhaseTransitionTestCase{ runPhaseTransitionTest(PhaseTransitionTestCase{
.initialPhase = CoordinatorStateEnum::kCommitting, .initialPhase = CoordinatorStateEnum::kCommitting, .transitionFn = [&]() {
.transitionFn = [&]() { _dao->transitionToAbortingPhase(_opCtx, now, abortReason); }}); _dao->transitionToAbortingPhase(_opCtx, now, abortReason);
}});
} }
TEST_F(ReshardingCoordinatorDaoFixture, UpdateSessionSetsSessionField) { TEST_F(ReshardingCoordinatorDaoFixture, UpdateSessionSetsSessionField) {

View File

@ -104,8 +104,9 @@ using MetricsPtr = std::unique_ptr<Metrics>;
const auto getMetrics = ServiceContext::declareDecoration<MetricsPtr>(); const auto getMetrics = ServiceContext::declareDecoration<MetricsPtr>();
const auto metricsRegisterer = ServiceContext::ConstructorActionRegisterer{ const auto metricsRegisterer = ServiceContext::ConstructorActionRegisterer{
"ShardingDataTransformMetrics", "ShardingDataTransformMetrics", [](ServiceContext* ctx) {
[](ServiceContext* ctx) { getMetrics(ctx) = std::make_unique<Metrics>(); }}; getMetrics(ctx) = std::make_unique<Metrics>();
}};
} // namespace } // namespace

View File

@ -656,7 +656,9 @@ std::unique_ptr<ReshardingMetrics> ReshardingMetrics::makeInstance_forTest(
StringData ReshardingMetrics::getStateString() const { StringData ReshardingMetrics::getStateString() const {
return visit(OverloadedVisitor{[](CoordinatorStateEnum state) { return idl::serialize(state); }, return visit(OverloadedVisitor{[](CoordinatorStateEnum state) { return idl::serialize(state); },
[](RecipientStateEnum state) { return idl::serialize(state); }, [](RecipientStateEnum state) { return idl::serialize(state); },
[](DonorStateEnum state) { return idl::serialize(state); }}, [](DonorStateEnum state) {
return idl::serialize(state);
}},
getState()); getState());
} }

View File

@ -140,7 +140,9 @@ public:
auto opTime = [opCtx] { auto opTime = [opCtx] {
WriteUnitOfWork wuow(opCtx); WriteUnitOfWork wuow(opCtx);
ScopeGuard guard{[&wuow] { wuow.commit(); }}; ScopeGuard guard{[&wuow] {
wuow.commit();
}};
return repl::getNextOpTime(opCtx); return repl::getNextOpTime(opCtx);
}(); }();
WriteUnitOfWork wuow(opCtx); WriteUnitOfWork wuow(opCtx);

View File

@ -1030,7 +1030,9 @@ TEST_F(TransactionCoordinatorServiceTest,
// Vote commit before the deadline // Vote commit before the deadline
onCommands({[&](const executor::RemoteCommandRequest&) { return kPrepareOk; }, onCommands({[&](const executor::RemoteCommandRequest&) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest&) { return kPrepareOk; }}); [&](const executor::RemoteCommandRequest&) {
return kPrepareOk;
}});
// Reach the deadline. // Reach the deadline.
network()->enterNetwork(); network()->enterNetwork();
@ -1075,7 +1077,9 @@ TEST_F(TransactionCoordinatorServiceTestSingleTxn,
// Simulate a participant voting to abort. // Simulate a participant voting to abort.
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }}); [&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();

View File

@ -548,7 +548,9 @@ TEST_F(TransactionCoordinatorDriverTest,
kTwoShardIdList); kTwoShardIdList);
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }}); [&](const executor::RemoteCommandRequest& request) {
return kPrepareOk;
}});
auto decision = future.get().decision(); auto decision = future.get().decision();
@ -587,7 +589,9 @@ TEST_F(TransactionCoordinatorDriverTest,
kTwoShardIdList); kTwoShardIdList);
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }}); [&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
auto decision = future.get().decision(); auto decision = future.get().decision();
ASSERT(decision.getDecision() == txn::CommitDecision::kAbort); ASSERT(decision.getDecision() == txn::CommitDecision::kAbort);
@ -1306,7 +1310,9 @@ TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnAbortAndCommi
auto commitDecisionFuture = coordinator->getDecision(); auto commitDecisionFuture = coordinator->getDecision();
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }}); [&](const executor::RemoteCommandRequest& request) {
return kPrepareOk;
}});
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
@ -1332,7 +1338,9 @@ TEST_F(TransactionCoordinatorTest,
auto commitDecisionFuture = coordinator->getDecision(); auto commitDecisionFuture = coordinator->getDecision();
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }}); [&](const executor::RemoteCommandRequest& request) {
return kNoSuchTransaction;
}});
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
@ -1357,9 +1365,10 @@ TEST_F(TransactionCoordinatorTest,
coordinator->runCommit(operationContext(), kTwoShardIdList); coordinator->runCommit(operationContext(), kTwoShardIdList);
auto commitDecisionFuture = coordinator->getDecision(); auto commitDecisionFuture = coordinator->getDecision();
onCommands( onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
{[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }, [&](const executor::RemoteCommandRequest& request) {
[&](const executor::RemoteCommandRequest& request) { return kTxnRetryCounterTooOld; }}); return kTxnRetryCounterTooOld;
}});
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();
@ -1411,7 +1420,9 @@ TEST_F(TransactionCoordinatorTest,
// One participant votes commit and other encounters retryable error // One participant votes commit and other encounters retryable error
onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; },
[&](const executor::RemoteCommandRequest& request) { return kRetryableError; }}); [&](const executor::RemoteCommandRequest& request) {
return kRetryableError;
}});
advanceClockAndExecuteScheduledTasks(); // Make sure the scheduled retry executes advanceClockAndExecuteScheduledTasks(); // Make sure the scheduled retry executes
// One participant votes abort after retry. // One participant votes abort after retry.
@ -1442,7 +1453,9 @@ TEST_F(TransactionCoordinatorTest,
// One participant votes abort and other encounters retryable error // One participant votes abort and other encounters retryable error
onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; }, onCommands({[&](const executor::RemoteCommandRequest& request) { return kNoSuchTransaction; },
[&](const executor::RemoteCommandRequest& request) { return kRetryableError; }}); [&](const executor::RemoteCommandRequest& request) {
return kRetryableError;
}});
advanceClockAndExecuteScheduledTasks(); // Make sure the cancellation callback is delivered advanceClockAndExecuteScheduledTasks(); // Make sure the cancellation callback is delivered
assertAbortSentAndRespondWithSuccess(); assertAbortSentAndRespondWithSuccess();

View File

@ -550,7 +550,9 @@ typename T::ConstructorActionRegisterer registerConstructorAction(
return typename T::ConstructorActionRegisterer{name, return typename T::ConstructorActionRegisterer{name,
prereqs, prereqs,
[name](T*) { actionListener.onConstruct(name); }, [name](T*) { actionListener.onConstruct(name); },
[name](T*) { actionListener.onDestruct(name); }}; [name](T*) {
actionListener.onDestruct(name);
}};
} }
const auto serviceContext1Registerer = registerConstructorAction<ServiceContext>("ServiceContext1"); const auto serviceContext1Registerer = registerConstructorAction<ServiceContext>("ServiceContext1");

View File

@ -1788,7 +1788,9 @@ TEST_F(DConcurrencyTestFixture,
auto result = task.get_future(); auto result = task.get_future();
stdx::thread taskThread{std::move(task)}; stdx::thread taskThread{std::move(task)};
ScopeGuard joinGuard{[&taskThread] { taskThread.join(); }}; ScopeGuard joinGuard{[&taskThread] {
taskThread.join();
}};
// Wait for the database X lock to conflict. // Wait for the database X lock to conflict.
while (!shard_role_details::getLocker(opCtx2)->hasLockPending()) { while (!shard_role_details::getLocker(opCtx2)->hasLockPending()) {

View File

@ -216,7 +216,9 @@ private:
return visit( return visit(
OverloadedVisitor{ OverloadedVisitor{
[](std::reference_wrapper<RecoveryUnit> ru) -> RecoveryUnit& { return ru; }, [](std::reference_wrapper<RecoveryUnit> ru) -> RecoveryUnit& { return ru; },
[](const std::function<RecoveryUnit&()>& ru) -> RecoveryUnit& { return ru(); }}, [](const std::function<RecoveryUnit&()>& ru) -> RecoveryUnit& {
return ru();
}},
_ru); _ru);
} }

View File

@ -570,13 +570,14 @@ DropIndexesReply dropIndexes(OperationContext* opCtx,
"CMD: dropIndexes", "CMD: dropIndexes",
logAttrs(collAcq->nss()), logAttrs(collAcq->nss()),
"uuid"_attr = collectionUUID, "uuid"_attr = collectionUUID,
"indexes"_attr = "indexes"_attr = visit(OverloadedVisitor{[](const std::string& arg) { return arg; },
visit(OverloadedVisitor{[](const std::string& arg) { return arg; }, [](const std::vector<std::string>& arg) {
[](const std::vector<std::string>& arg) { return boost::algorithm::join(arg, ",");
return boost::algorithm::join(arg, ","); },
}, [](const BSONObj& arg) {
[](const BSONObj& arg) { return arg.toString(); }}, return arg.toString();
index)); }},
index));
} }
DropIndexesReply reply; DropIndexesReply reply;

View File

@ -633,8 +633,9 @@ StatusWith<std::vector<BSONObj>> Shard::runAggregationWithResult(
Shard::RetryStrategy::RequestStartTransactionState isStartTransaction = Shard::RetryStrategy::RequestStartTransactionState isStartTransaction =
Shard::RetryStrategy::extractRequestTransactionState(aggRequest.getGenericArguments()); Shard::RetryStrategy::extractRequestTransactionState(aggRequest.getGenericArguments());
RetryStrategyWithFailureRetryHook retryStrategy{ RetryStrategyWithFailureRetryHook retryStrategy{
RetryStrategy{*this, retryPolicy, isStartTransaction}, RetryStrategy{*this, retryPolicy, isStartTransaction}, [&](Status s) {
[&](Status s) { aggResult.clear(); }}; aggResult.clear();
}};
auto status = auto status =
runWithRetryStrategy(opCtx, retryStrategy, [&](const TargetingMetadata& targetingMetadata) { runWithRetryStrategy(opCtx, retryStrategy, [&](const TargetingMetadata& targetingMetadata) {

View File

@ -183,8 +183,10 @@ std::unique_ptr<ShardRegistry> ShardingMongoDTestFixture::makeShardRegistry(
std::make_unique<ShardFactory>(std::move(buildersMap), std::move(targeterFactory)); std::make_unique<ShardFactory>(std::move(buildersMap), std::move(targeterFactory));
auto shardRemovalHooks = std::vector<ShardRegistry::ShardRemovalHook>{ auto shardRemovalHooks = std::vector<ShardRegistry::ShardRemovalHook>{
[&shardSharedStateCache = ShardSharedStateCache::get(service)]( [&shardSharedStateCache =
const ShardId& removedShard) { shardSharedStateCache.forgetShardState(removedShard); }}; ShardSharedStateCache::get(service)](const ShardId& removedShard) {
shardSharedStateCache.forgetShardState(removedShard);
}};
return std::make_unique<ShardRegistry>( return std::make_unique<ShardRegistry>(
getServiceContext(), std::move(shardFactory), configConnStr, std::move(shardRemovalHooks)); getServiceContext(), std::move(shardFactory), configConnStr, std::move(shardRemovalHooks));

View File

@ -355,7 +355,9 @@ std::string toString(const StorageEngine::OldestActiveTransactionTimestampResult
void setKeyOnCursor(WT_CURSOR* c, const std::variant<std::span<const char>, int64_t>& key) { void setKeyOnCursor(WT_CURSOR* c, const std::variant<std::span<const char>, int64_t>& key) {
std::visit(OverloadedVisitor{ std::visit(OverloadedVisitor{
[&](const std::span<const char> k) { c->set_key(c, WiredTigerItem{k}.get()); }, [&](const std::span<const char> k) { c->set_key(c, WiredTigerItem{k}.get()); },
[&](int64_t k) { c->set_key(c, k); }}, [&](int64_t k) {
c->set_key(c, k);
}},
key); key);
} }

View File

@ -449,7 +449,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadUncommittedIsolation) {
auto session = ru2->getSession(); auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly()); ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }}; ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor; WT_CURSOR* cursor;
getCursor(ru1, &cursor); getCursor(ru1, &cursor);
@ -474,7 +476,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadCommittedIsolation) {
auto session = ru2->getSession(); auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly()); ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }}; ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor; WT_CURSOR* cursor;
getCursor(ru1, &cursor); getCursor(ru1, &cursor);
@ -499,7 +503,9 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, SnapshotIsolation) {
auto session = ru2->getSession(); auto session = ru2->getSession();
ru1->beginUnitOfWork(clientAndCtx1.second->readOnly()); ru1->beginUnitOfWork(clientAndCtx1.second->readOnly());
ScopeGuard guard{[this] { ru1->abortUnitOfWork(); }}; ScopeGuard guard{[this] {
ru1->abortUnitOfWork();
}};
WT_CURSOR* cursor; WT_CURSOR* cursor;
getCursor(ru1, &cursor); getCursor(ru1, &cursor);

View File

@ -62,7 +62,9 @@ WiredTigerStats::WiredTigerStats(WiredTigerSession& session) {
"Unable to open statistics cursor", "Unable to open statistics cursor",
!session.open_cursor("statistics:session", nullptr, "statistics=(fast)", &c)); !session.open_cursor("statistics:session", nullptr, "statistics=(fast)", &c));
ScopeGuard guard{[c] { c->close(c); }}; ScopeGuard guard{[c] {
c->close(c);
}};
// Get all the stats // Get all the stats
while (c->next(c) == 0) { while (c->next(c) == 0) {

View File

@ -1653,8 +1653,9 @@ TEST_F(BucketCatalogTest, CannotConcurrentlyCommitBatchesForSameBucket) {
{ {
auto task = RunBackgroundTaskAndWaitForFailpoint{ auto task = RunBackgroundTaskAndWaitForFailpoint{
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation", "hangTimeSeriesBatchPrepareWaitingForConflictingOperation", [&]() {
[&]() { ASSERT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns1))); }}; ASSERT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns1)));
}};
// Finish the first batch. // Finish the first batch.
finish(*_bucketCatalog, batch1); finish(*_bucketCatalog, batch1);
@ -1689,8 +1690,9 @@ TEST_F(BucketCatalogTest, AbortingBatchEnsuresBucketIsEventuallyClosed) {
{ {
auto task = RunBackgroundTaskAndWaitForFailpoint{ auto task = RunBackgroundTaskAndWaitForFailpoint{
"hangTimeSeriesBatchPrepareWaitingForConflictingOperation", "hangTimeSeriesBatchPrepareWaitingForConflictingOperation", [&]() {
[&]() { ASSERT_NOT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns2))); }}; ASSERT_NOT_OK(prepareCommit(*_bucketCatalog, batch2, _getCollator(_ns2)));
}};
// If we abort the third batch, it should abort the second one too, as it isn't prepared. // If we abort the third batch, it should abort the second one too, as it isn't prepared.
// However, since the first batch is prepared, we can't abort it or clean up the bucket. We // However, since the first batch is prepared, we can't abort it or clean up the bucket. We

View File

@ -77,7 +77,9 @@ public:
return bucketState == BucketState::kCleared || return bucketState == BucketState::kCleared ||
bucketState == BucketState::kPreparedAndCleared; bucketState == BucketState::kPreparedAndCleared;
}, },
[](DirectWriteCounter dwcount) { return false; }}, [](DirectWriteCounter dwcount) {
return false;
}},
*state); *state);
} }

View File

@ -157,7 +157,9 @@ void appendElementToBuilder(std::variant<mutablebson::Element, BSONElement> elem
element.writeArrayTo(&subBuilder); element.writeArrayTo(&subBuilder);
} }
}, },
[&](BSONElement element) { builder->appendAs(element, fieldName); }}, [&](BSONElement element) {
builder->appendAs(element, fieldName);
}},
elem); elem);
} }
@ -537,9 +539,10 @@ boost::optional<std::pair<size_t, ArrayDiffReader::ArrayModification>> ArrayDiff
str::stream() << "expected sub diff at index " << idx << " but got " << next, str::stream() << "expected sub diff at index " << idx << " but got " << next,
next.type() == BSONType::object); next.type() == BSONType::object);
auto modification = visit( auto modification = visit(OverloadedVisitor{[](const auto& reader) -> ArrayModification {
OverloadedVisitor{[](const auto& reader) -> ArrayModification { return {reader}; }}, return {reader};
getReader(next.embeddedObject())); }},
getReader(next.embeddedObject()));
return {{idx, modification}}; return {{idx, modification}};
} else { } else {
uasserted(4770502, uasserted(4770502,

View File

@ -87,7 +87,9 @@ void VersionContext::resetToOperationWithoutOFCV() {
BSONObj VersionContext::toBSON() const { BSONObj VersionContext::toBSON() const {
return visit( return visit(
OverloadedVisitor{[](const VersionContextMetadata& metadata) { return metadata.toBSON(); }, OverloadedVisitor{[](const VersionContextMetadata& metadata) { return metadata.toBSON(); },
[](auto&&) -> BSONObj { MONGO_UNREACHABLE_TASSERT(10083532); }}, [](auto&&) -> BSONObj {
MONGO_UNREACHABLE_TASSERT(10083532);
}},
_metadataOrTag); _metadataOrTag);
} }

View File

@ -88,7 +88,9 @@ void serializeWriteConcernW(const WriteConcernW& w, StringData fieldName, BSONOb
builder->appendNumber(fieldName, static_cast<long long>(wNumNodes)); builder->appendNumber(fieldName, static_cast<long long>(wNumNodes));
}, },
[&](const std::string& wMode) { builder->append(fieldName, wMode); }, [&](const std::string& wMode) { builder->append(fieldName, wMode); },
[&](WTags wTags) { builder->append(fieldName, wTags); }}, [&](WTags wTags) {
builder->append(fieldName, wTags);
}},
w); w);
} }

View File

@ -91,7 +91,8 @@ class EmbeddedBuilder {
public: public:
explicit EmbeddedBuilder(BSONObjBuilder* root) { explicit EmbeddedBuilder(BSONObjBuilder* root) {
// Root isn't owned, so give it a nop deleter. // Root isn't owned, so give it a nop deleter.
_builders.push_back({{}, {root, [](auto) {}}}); _builders.push_back({{}, {root, [](auto) {
}}});
} }
void appendAs(const BSONElement& e, StringData name) { void appendAs(const BSONElement& e, StringData name) {

View File

@ -165,9 +165,11 @@ public:
} }
}; };
const auto implRegisterer = ServiceContext::ConstructorActionRegisterer{ const auto implRegisterer =
"RemoteCommmandRunner", ServiceContext::ConstructorActionRegisterer{"RemoteCommmandRunner", [](ServiceContext* ctx) {
[](ServiceContext* ctx) { getRCRImpl(ctx) = std::make_unique<AsyncRPCRunnerImpl>(); }}; getRCRImpl(ctx) =
std::make_unique<AsyncRPCRunnerImpl>();
}};
AsyncRPCRunner* AsyncRPCRunner::get(ServiceContext* svcCtx) { AsyncRPCRunner* AsyncRPCRunner::get(ServiceContext* svcCtx) {
return getRCRImpl(svcCtx).get(); return getRCRImpl(svcCtx).get();

View File

@ -354,7 +354,9 @@ TEST_F(ThreadPoolExecutorTest, CancelFromAnotherThread) {
finishedShutdown.get(); finishedShutdown.get();
}); });
unittest::JoinThread th{[&] { executor.cancel(swCbHandle.getValue()); }}; unittest::JoinThread th{[&] {
executor.cancel(swCbHandle.getValue());
}};
startedCancellation.get(); startedCancellation.get();
shutdownExecutorThread(); shutdownExecutorThread();

View File

@ -121,7 +121,8 @@ GetTenantIDFn& getTenantID() {
return *fn; return *fn;
} }
LogCounterCallback& getLogCounterCallback() { LogCounterCallback& getLogCounterCallback() {
static StaticImmortal<LogCounterCallback> fn{[]() {}}; static StaticImmortal<LogCounterCallback> fn{[]() {
}};
return *fn; return *fn;
} }
} // namespace } // namespace

View File

@ -74,12 +74,10 @@ private:
}; };
/** Helper to create MetricName instances. */ /** Helper to create MetricName instances. */
class MONGO_MOD_FILE_PRIVATE MetricNameMaker { class MONGO_MOD_FILE_PRIVATE MetricNameMaker{public : static constexpr MetricName make(
public: StringData name){return MetricName(name, Passkey<MetricNameMaker>{});
static constexpr MetricName make(StringData name) { } // namespace otel::metrics
return MetricName(name, Passkey<MetricNameMaker>{}); }; // namespace mongo
}
};
/** /**
* Central registry of OpenTelemetry metric names used in the server. When adding a new metric to * Central registry of OpenTelemetry metric names used in the server. When adding a new metric to

View File

@ -222,7 +222,9 @@ TEST_F(PrometheusFileExporterTest, SkippedExportIncrementsCounter) {
// guarantee that one export is skipped. // guarantee that one export is skipped.
auto [promise, future] = makePromiseFuture<void>(); auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter = std::unique_ptr<PushMetricExporter> exporter =
makeExporter(/*options=*/{.testOnlyFailpointCallback = [&future]() { future.wait(); }}); makeExporter(/*options=*/{.testOnlyFailpointCallback = [&future]() {
future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback", FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true)); BSON("UnlockOnly" << true));
@ -493,8 +495,9 @@ TEST_F(PrometheusFileExporterTest, ExactlyMaxConsecutiveSkipsIsOk) {
// The writer thread blocks on this future. // The writer thread blocks on this future.
auto [promise, future] = makePromiseFuture<void>(); auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter = makeExporter( std::unique_ptr<PushMetricExporter> exporter = makeExporter(
/*options=*/{.maxConsecutiveFailures = 3, /*options=*/{.maxConsecutiveFailures = 3, .testOnlyFailpointCallback = [&future]() {
.testOnlyFailpointCallback = [&future]() { future.wait(); }}); future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback", FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true)); BSON("UnlockOnly" << true));
@ -514,8 +517,9 @@ DEATH_TEST_F(PrometheusFileExporterDeathTest,
// The writer thread blocks on this future. // The writer thread blocks on this future.
auto [promise, future] = makePromiseFuture<void>(); auto [promise, future] = makePromiseFuture<void>();
std::unique_ptr<PushMetricExporter> exporter = makeExporter( std::unique_ptr<PushMetricExporter> exporter = makeExporter(
/*options=*/{.maxConsecutiveFailures = 3, /*options=*/{.maxConsecutiveFailures = 3, .testOnlyFailpointCallback = [&future]() {
.testOnlyFailpointCallback = [&future]() { future.wait(); }}); future.wait();
}});
FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback", FailPointEnableBlock fp("metricsPrometheusFileExporterThreadCallback",
BSON("UnlockOnly" << true)); BSON("UnlockOnly" << true));

View File

@ -370,7 +370,9 @@ private:
// See documentWithoutMongosInfo(). // See documentWithoutMongosInfo().
Deferred<BSONObj (*)(const BSONObj&)> _documentWithoutMongosInfo{ Deferred<BSONObj (*)(const BSONObj&)> _documentWithoutMongosInfo{
[](const BSONObj& fullDocument) { return fullDocument.removeField("mongos"); }}; [](const BSONObj& fullDocument) {
return fullDocument.removeField("mongos");
}};
// See hashWithoutMongosInfo(). // See hashWithoutMongosInfo().
Deferred<size_t (*)(const BSONObj&)> _hashWithoutMongos{simpleHash}; Deferred<size_t (*)(const BSONObj&)> _hashWithoutMongos{simpleHash};

View File

@ -38,6 +38,7 @@ void visit(DocsNeededBoundsContext* ctx, const T&) {
} }
const ServiceContext::ConstructorActionRegisterer DocsNeededBoundsRegisterer{ const ServiceContext::ConstructorActionRegisterer DocsNeededBoundsRegisterer{
"DocsNeededBoundsRegistererMongos", "DocsNeededBoundsRegistererMongos", [](ServiceContext* service) {
[](ServiceContext* service) { registerMongosVisitor<DocsNeededBoundsContext>(service); }}; registerMongosVisitor<DocsNeededBoundsContext>(service);
}};
} // namespace mongo } // namespace mongo

View File

@ -156,7 +156,9 @@ void BatchedCommandRequest::unsetLegacyRuntimeConstants() {
_visit(OverloadedVisitor{ _visit(OverloadedVisitor{
[](write_ops::InsertCommandRequest&) {}, [](write_ops::InsertCommandRequest&) {},
[&](write_ops::UpdateCommandRequest& op) { op.setLegacyRuntimeConstants(boost::none); }, [&](write_ops::UpdateCommandRequest& op) { op.setLegacyRuntimeConstants(boost::none); },
[&](write_ops::DeleteCommandRequest& op) { op.setLegacyRuntimeConstants(boost::none); }}); [&](write_ops::DeleteCommandRequest& op) {
op.setLegacyRuntimeConstants(boost::none);
}});
} }
const boost::optional<LegacyRuntimeConstants>& BatchedCommandRequest::getLegacyRuntimeConstants() const boost::optional<LegacyRuntimeConstants>& BatchedCommandRequest::getLegacyRuntimeConstants()
@ -193,7 +195,9 @@ const boost::optional<BSONObj>& BatchedCommandRequest::getLet() const {
void BatchedCommandRequest::setLet(boost::optional<mongo::BSONObj> value) { void BatchedCommandRequest::setLet(boost::optional<mongo::BSONObj> value) {
_visit(OverloadedVisitor{[&](write_ops::InsertCommandRequest& op) {}, _visit(OverloadedVisitor{[&](write_ops::InsertCommandRequest& op) {},
[&](write_ops::UpdateCommandRequest& op) { op.setLet(value); }, [&](write_ops::UpdateCommandRequest& op) { op.setLet(value); },
[&](write_ops::DeleteCommandRequest& op) { op.setLet(value); }}); [&](write_ops::DeleteCommandRequest& op) {
op.setLet(value);
}});
} }
void BatchedCommandRequest::evaluateAndReplaceLetParams(OperationContext* opCtx) { void BatchedCommandRequest::evaluateAndReplaceLetParams(OperationContext* opCtx) {

View File

@ -203,7 +203,9 @@ const BSONObj& BatchWriteCommandRefImpl::getFilter(int index) const {
index, index,
OverloadedVisitor{ OverloadedVisitor{
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getQ(); }, [&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getQ(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return deleteOp.getQ(); }}); [&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return deleteOp.getQ();
}});
} }
const BSONObj& BatchWriteCommandRefImpl::getHint(int index) const { const BSONObj& BatchWriteCommandRefImpl::getHint(int index) const {
@ -212,7 +214,9 @@ const BSONObj& BatchWriteCommandRefImpl::getHint(int index) const {
index, index,
OverloadedVisitor{ OverloadedVisitor{
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getHint(); }, [&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getHint(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return deleteOp.getHint(); }}); [&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return deleteOp.getHint();
}});
} }
const BSONObj& BatchWriteCommandRefImpl::getDocument(int index) const { const BSONObj& BatchWriteCommandRefImpl::getDocument(int index) const {
@ -221,12 +225,14 @@ const BSONObj& BatchWriteCommandRefImpl::getDocument(int index) const {
} }
bool BatchWriteCommandRefImpl::getMulti(int index) const { bool BatchWriteCommandRefImpl::getMulti(int index) const {
return visitOpData( return visitOpData(index,
index, OverloadedVisitor{[&](const BSONObj& insertDoc) { return false; },
OverloadedVisitor{ [&](const write_ops::UpdateOpEntry& updateOp) {
[&](const BSONObj& insertDoc) { return false; }, return updateOp.getMulti();
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.getMulti(); }, },
[&](const write_ops::DeleteOpEntry& deleteOp) { return deleteOp.getMulti(); }}); [&](const write_ops::DeleteOpEntry& deleteOp) {
return deleteOp.getMulti();
}});
} }
const NamespaceString& BatchWriteCommandRefImpl::getNss(int index) const { const NamespaceString& BatchWriteCommandRefImpl::getNss(int index) const {
@ -264,12 +270,14 @@ const write_ops::UpdateModification& BatchWriteCommandRefImpl::getUpdateMods(int
} }
bool BatchWriteCommandRefImpl::getUpsert(int index) const { bool BatchWriteCommandRefImpl::getUpsert(int index) const {
return visitOpData( return visitOpData(index,
index, OverloadedVisitor{[&](const BSONObj& insertDoc) { return false; },
OverloadedVisitor{ [&](const write_ops::UpdateOpEntry& updateOp) {
[&](const BSONObj& insertDoc) { return false; }, return updateOp.getUpsert();
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.getUpsert(); }, },
[&](const write_ops::DeleteOpEntry& deleteOp) { return false; }}); [&](const write_ops::DeleteOpEntry& deleteOp) {
return false;
}});
} }
OptionalBool BatchWriteCommandRefImpl::getUpsertSupplied(int index) const { OptionalBool BatchWriteCommandRefImpl::getUpsertSupplied(int index) const {
@ -308,16 +316,20 @@ boost::optional<mongo::BSONObj> BatchWriteCommandRefImpl::getSort(int index) con
OverloadedVisitor{ OverloadedVisitor{
[&](const BSONObj& insertDoc) -> RetT { return boost::none; }, [&](const BSONObj& insertDoc) -> RetT { return boost::none; },
[&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getSort(); }, [&](const write_ops::UpdateOpEntry& updateOp) -> RetT { return updateOp.getSort(); },
[&](const write_ops::DeleteOpEntry& deleteOp) -> RetT { return boost::none; }}); [&](const write_ops::DeleteOpEntry& deleteOp) -> RetT {
return boost::none;
}});
} }
BSONObj BatchWriteCommandRefImpl::toBSON(int index) const { BSONObj BatchWriteCommandRefImpl::toBSON(int index) const {
return visitOpData( return visitOpData(index,
index, OverloadedVisitor{[&](const BSONObj& insertDoc) { return insertDoc; },
OverloadedVisitor{ [&](const write_ops::UpdateOpEntry& updateOp) {
[&](const BSONObj& insertDoc) { return insertDoc; }, return updateOp.toBSON();
[&](const write_ops::UpdateOpEntry& updateOp) { return updateOp.toBSON(); }, },
[&](const write_ops::DeleteOpEntry& deleteOp) { return deleteOp.toBSON(); }}); [&](const write_ops::DeleteOpEntry& deleteOp) {
return deleteOp.toBSON();
}});
} }
int BulkWriteCommandRefImpl::estimateOpSizeInBytes(int index) const { int BulkWriteCommandRefImpl::estimateOpSizeInBytes(int index) const {
@ -377,7 +389,9 @@ const boost::optional<BSONObj>& BulkWriteCommandRefImpl::getCollation(int index)
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteInsertOp& insertOp) -> RetT { return kMissingBSONObj; }, [&](const BulkWriteInsertOp& insertOp) -> RetT { return kMissingBSONObj; },
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getCollation(); }, [&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getCollation(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getCollation(); }}); [&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getCollation();
}});
} }
boost::optional<BSONObj> BulkWriteCommandRefImpl::getConstants(int index) const { boost::optional<BSONObj> BulkWriteCommandRefImpl::getConstants(int index) const {
@ -392,7 +406,9 @@ const BSONObj& BulkWriteCommandRefImpl::getFilter(int index) const {
index, index,
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getFilter(); }, [&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getFilter(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getFilter(); }}); [&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getFilter();
}});
} }
boost::optional<UUID> BulkWriteCommandRefImpl::getSampleId(int index) const { boost::optional<UUID> BulkWriteCommandRefImpl::getSampleId(int index) const {
@ -401,7 +417,9 @@ boost::optional<UUID> BulkWriteCommandRefImpl::getSampleId(int index) const {
index, index,
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSampleId(); }, [&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSampleId(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getSampleId(); }}); [&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getSampleId();
}});
} }
const BSONObj& BulkWriteCommandRefImpl::getHint(int index) const { const BSONObj& BulkWriteCommandRefImpl::getHint(int index) const {
@ -410,7 +428,9 @@ const BSONObj& BulkWriteCommandRefImpl::getHint(int index) const {
index, index,
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getHint(); }, [&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getHint(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return deleteOp.getHint(); }}); [&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return deleteOp.getHint();
}});
} }
const BSONObj& BulkWriteCommandRefImpl::getDocument(int index) const { const BSONObj& BulkWriteCommandRefImpl::getDocument(int index) const {
@ -424,7 +444,9 @@ bool BulkWriteCommandRefImpl::getMulti(int index) const {
index, index,
OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; }, OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; },
[&](const BulkWriteUpdateOp& updateOp) { return updateOp.getMulti(); }, [&](const BulkWriteUpdateOp& updateOp) { return updateOp.getMulti(); },
[&](const BulkWriteDeleteOp& deleteOp) { return deleteOp.getMulti(); }}); [&](const BulkWriteDeleteOp& deleteOp) {
return deleteOp.getMulti();
}});
} }
const NamespaceString& BulkWriteCommandRefImpl::getNss(int index) const { const NamespaceString& BulkWriteCommandRefImpl::getNss(int index) const {
@ -445,7 +467,9 @@ BatchedCommandRequest::BatchType BulkWriteCommandRefImpl::getOpType(int index) c
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteInsertOp&) { return BatchedCommandRequest::BatchType_Insert; }, [&](const BulkWriteInsertOp&) { return BatchedCommandRequest::BatchType_Insert; },
[&](const BulkWriteUpdateOp&) { return BatchedCommandRequest::BatchType_Update; }, [&](const BulkWriteUpdateOp&) { return BatchedCommandRequest::BatchType_Update; },
[&](const BulkWriteDeleteOp&) { return BatchedCommandRequest::BatchType_Delete; }}); [&](const BulkWriteDeleteOp&) {
return BatchedCommandRequest::BatchType_Delete;
}});
} }
const write_ops::UpdateModification& BulkWriteCommandRefImpl::getUpdateMods(int index) const { const write_ops::UpdateModification& BulkWriteCommandRefImpl::getUpdateMods(int index) const {
@ -477,7 +501,9 @@ bool BulkWriteCommandRefImpl::getUpsert(int index) const {
index, index,
OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; }, OverloadedVisitor{[&](const BulkWriteInsertOp& insertOp) { return false; },
[&](const BulkWriteUpdateOp& updateOp) { return updateOp.getUpsert(); }, [&](const BulkWriteUpdateOp& updateOp) { return updateOp.getUpsert(); },
[&](const BulkWriteDeleteOp& deleteOp) { return false; }}); [&](const BulkWriteDeleteOp& deleteOp) {
return false;
}});
} }
const boost::optional<mongo::EncryptionInformation>& const boost::optional<mongo::EncryptionInformation>&
@ -496,7 +522,9 @@ boost::optional<mongo::BSONObj> BulkWriteCommandRefImpl::getSort(int index) cons
OverloadedVisitor{ OverloadedVisitor{
[&](const BulkWriteInsertOp& insertOp) -> RetT { return boost::none; }, [&](const BulkWriteInsertOp& insertOp) -> RetT { return boost::none; },
[&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSort(); }, [&](const BulkWriteUpdateOp& updateOp) -> RetT { return updateOp.getSort(); },
[&](const BulkWriteDeleteOp& deleteOp) -> RetT { return boost::none; }}); [&](const BulkWriteDeleteOp& deleteOp) -> RetT {
return boost::none;
}});
} }
BSONObj BulkWriteCommandRefImpl::toBSON(int index) const { BSONObj BulkWriteCommandRefImpl::toBSON(int index) const {

View File

@ -218,7 +218,9 @@ int recursionTestImpl(bool useSigAltStack) {
void* deepestAddress; void* deepestAddress;
const std::function<void()> recur; const std::function<void()> recur;
}; };
MostlyInfiniteRecursion recursion = {0, &recursion, [&] { recursion.run(); }}; MostlyInfiniteRecursion recursion = {0, &recursion, [&] {
recursion.run();
}};
// When the signal handler fires, it will return to this sigsetjmp call, causing // When the signal handler fires, it will return to this sigsetjmp call, causing
// it to return a nonzero value. This makes the child thread viable again, and // it to return a nonzero value. This makes the child thread viable again, and

View File

@ -126,7 +126,9 @@ class ConnectionThread {
public: public:
explicit ConnectionThread(int port) : ConnectionThread(port, nullptr) {} explicit ConnectionThread(int port) : ConnectionThread(port, nullptr) {}
ConnectionThread(int port, std::function<void(ConnectionThread&)> onConnect) ConnectionThread(int port, std::function<void(ConnectionThread&)> onConnect)
: _port{port}, _onConnect{std::move(onConnect)}, _thread{[this] { _run(); }} {} : _port{port}, _onConnect{std::move(onConnect)}, _thread{[this] {
_run();
}} {}
~ConnectionThread() { ~ConnectionThread() {
LOGV2(6109500, "connection: Tx stop request"); LOGV2(6109500, "connection: Tx stop request");
@ -1064,7 +1066,9 @@ TEST(AsioTransportLayer, EgressConnectionResetByPeerDuringSessionCtor) {
conn->socket.close(); conn->socket.close();
fp.reset(); fp.reset();
}); });
test::JoinThread ioThread{[&] { ioContext.run(); }}; test::JoinThread ioThread{[&] {
ioContext.run();
}};
ScopeGuard ioContextStop = [&] { ScopeGuard ioContextStop = [&] {
ioContext.stop(); ioContext.stop();
}; };
@ -1102,7 +1106,9 @@ TEST(AsioTransportLayer, ConfirmSocketSetOptionOnResetConnections) {
sleepFor(Seconds{1}); sleepFor(Seconds{1});
accepted.set(true); accepted.set(true);
}); });
test::JoinThread ioThread{[&] { ioContext.run(); }}; test::JoinThread ioThread{[&] {
ioContext.run();
}};
ScopeGuard ioContextStop = [&] { ScopeGuard ioContextStop = [&] {
ioContext.stop(); ioContext.stop();
}; };

View File

@ -82,7 +82,9 @@ struct MONGO_MOD_NEEDS_REPLACEMENT SessionThread {
struct StopException {}; struct StopException {};
explicit SessionThread(std::shared_ptr<transport::Session> s) explicit SessionThread(std::shared_ptr<transport::Session> s)
: _session{std::move(s)}, _thread{[this] { _run(); }} {} : _session{std::move(s)}, _thread{[this] {
_run();
}} {}
~SessionThread() { ~SessionThread() {
if (!_thread.joinable()) if (!_thread.joinable())

View File

@ -63,7 +63,9 @@ public:
/** Spawn and return a `stdx::thread` that invokes `f` as if by `exec(f)`. */ /** Spawn and return a `stdx::thread` that invokes `f` as if by `exec(f)`. */
template <typename F> template <typename F>
stdx::thread spawn(F&& f) { stdx::thread spawn(F&& f) {
return stdx::thread{[this, f = std::move(f)]() mutable { exec(std::move(f)); }}; return stdx::thread{[this, f = std::move(f)]() mutable {
exec(std::move(f));
}};
} }
/** Spawn a thread that will invoke monitor.notifyDone()` when it finishes. */ /** Spawn a thread that will invoke monitor.notifyDone()` when it finishes. */

View File

@ -60,7 +60,9 @@ TEST(ThreadAssertionMonitor, Trivial) {
TEST(ThreadAssertionMonitor, ControllerInStdxThread) { TEST(ThreadAssertionMonitor, ControllerInStdxThread) {
ThreadAssertionMonitor monitor; ThreadAssertionMonitor monitor;
stdx::thread{[&] { monitor.notifyDone(); }}.join(); stdx::thread{[&] {
monitor.notifyDone();
}}.join();
} }
TEST(ThreadAssertionMonitor, OnlyControllerInSpawn) { TEST(ThreadAssertionMonitor, OnlyControllerInSpawn) {

View File

@ -178,7 +178,9 @@ void BackgroundJob::go() {
// If the job is already 'done', for instance because it was cancelled or already // If the job is already 'done', for instance because it was cancelled or already
// finished, ignore additional requests to run the job. // finished, ignore additional requests to run the job.
if (_status->state == NotStarted) { if (_status->state == NotStarted) {
stdx::thread{[this] { jobBody(); }}.detach(); stdx::thread{[this] {
jobBody();
}}.detach();
_status->state = Running; _status->state = Running;
} }
} }

View File

@ -286,7 +286,7 @@ struct UFDeductionHelper {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {}; struct UFDeductionHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...) &> : std::type_identity<Ret(Args...)> {}; struct UFDeductionHelper<Ret (Class::*)(Args...)&> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct UFDeductionHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {}; struct UFDeductionHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>

View File

@ -120,7 +120,9 @@ TEST(UniqueFunctionTest, construct_simple_unique_function_from_lambda) {
// Explicit construction // Explicit construction
{ {
RunDetection<0> runDetection; RunDetection<0> runDetection;
mongo::unique_function<void()> uf{[] { RunDetection<0>::itRan = true; }}; mongo::unique_function<void()> uf{[] {
RunDetection<0>::itRan = true;
}};
uf(); uf();

View File

@ -304,7 +304,9 @@ using unittest::JoinThread;
TEST(SharedFuture, ConcurrentTest_Simple) { TEST(SharedFuture, ConcurrentTest_Simple) {
SharedPromise<void> promise; SharedPromise<void> promise;
auto shared = promise.getFuture(); auto shared = promise.getFuture();
JoinThread thread{stdx::thread{[&] { shared.get(); }}}; JoinThread thread{stdx::thread{[&] {
shared.get();
}}};
std::this_thread::yield(); // Slightly increase the chance of racing. std::this_thread::yield(); // Slightly increase the chance of racing.
promise.emplaceValue(); promise.emplaceValue();
} }

View File

@ -619,8 +619,9 @@ public:
ExtractRetryParameters extractRetryParameters = {}) && { ExtractRetryParameters extractRetryParameters = {}) && {
using ReturnType = FutureContinuationResult<Callable, const TargetingMetadata&>; using ReturnType = FutureContinuationResult<Callable, const TargetingMetadata&>;
return mongo::AsyncTry{ return mongo::AsyncTry{[body = std::move(_body), strategy] {
[body = std::move(_body), strategy] { return body(strategy->getTargetingMetadata()); }} return body(strategy->getTargetingMetadata());
}}
.until([strategy, extractRetryParameters = std::move(extractRetryParameters)]( .until([strategy, extractRetryParameters = std::move(extractRetryParameters)](
const StatusOrStatusWith<ReturnType>& swResult) { const StatusOrStatusWith<ReturnType>& swResult) {
auto result = extractRetryParameters(swResult); auto result = extractRetryParameters(swResult);

View File

@ -82,7 +82,9 @@ public:
std::vector<std::tuple<void*, size_t, size_t>> upstreamDeallocations; std::vector<std::tuple<void*, size_t, size_t>> upstreamDeallocations;
MockResource<> mockResource{ MockResource<> mockResource{
[&](void* p, size_t sz, size_t al) { upstreamAllocations.push_back({p, sz, al}); }, [&](void* p, size_t sz, size_t al) { upstreamAllocations.push_back({p, sz, al}); },
[&](void* p, size_t sz, size_t al) { upstreamDeallocations.push_back({p, sz, al}); }}; [&](void* p, size_t sz, size_t al) {
upstreamDeallocations.push_back({p, sz, al});
}};
}; };
TEST_F(MonotonicBufferResourceTest, UpstreamAllocationsReduced) { TEST_F(MonotonicBufferResourceTest, UpstreamAllocationsReduced) {

View File

@ -69,7 +69,9 @@ private:
template <typename T> template <typename T>
static inline VTable forT = VTable{+[](void* t) { static_cast<T*>(t)->lock(); }, static inline VTable forT = VTable{+[](void* t) { static_cast<T*>(t)->lock(); },
+[](void* t) { static_cast<T*>(t)->unlock(); }}; +[](void* t) {
static_cast<T*>(t)->unlock();
}};
void* _underlyingLock; void* _underlyingLock;
const VTable* _vtable; const VTable* _vtable;

View File

@ -144,7 +144,9 @@ public:
bool containsClusterMembershipConfig = false; bool containsClusterMembershipConfig = false;
bool containsOverrideClusterMembershipConfig = false; bool containsOverrideClusterMembershipConfig = false;
auto visitor = OverloadedVisitor{[](const SSLX509Name&) { return false; }, auto visitor = OverloadedVisitor{[](const SSLX509Name&) { return false; },
[](const std::string&) { return true; }}; [](const std::string&) {
return true;
}};
if (_clusterAuthX509Config._configCriteria) { if (_clusterAuthX509Config._configCriteria) {
containsClusterMembershipConfig = containsClusterMembershipConfig =

View File

@ -53,7 +53,7 @@ struct SigHelper<Ret (*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {}; struct SigHelper<Ret (Class::*)(Args...)> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...) &> : std::type_identity<Ret(Args...)> {}; struct SigHelper<Ret (Class::*)(Args...)&> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>
struct SigHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {}; struct SigHelper<Ret (Class::*)(Args...) const> : std::type_identity<Ret(Args...)> {};
template <typename Class, typename Ret, typename... Args> template <typename Class, typename Ret, typename... Args>

View File

@ -525,15 +525,20 @@ public:
}; };
std::set<CpuId, decltype(cmp)> cpuIds(cmp); std::set<CpuId, decltype(cmp)> cpuIds(cmp);
CpuInfoParser cpuInfoParser{ CpuInfoParser cpuInfoParser{{
{ {"physical id",
{"physical id", [&](const std::string& value) { parsedCpuId.physical = value; }}, [&](const std::string& value) {
{"core id", [&](const std::string& value) { parsedCpuId.core = value; }}, parsedCpuId.physical = value;
}, }},
[&]() { {"core id",
cpuIds.insert(parsedCpuId); [&](const std::string& value) {
parsedCpuId = CpuId{}; parsedCpuId.core = value;
}}; }},
},
[&]() {
cpuIds.insert(parsedCpuId);
parsedCpuId = CpuId{};
}};
cpuInfoParser.run(); cpuInfoParser.run();
physicalCores = cpuIds.size(); physicalCores = cpuIds.size();
@ -545,11 +550,14 @@ public:
static int getNumCpuSockets() { static int getNumCpuSockets() {
std::set<std::string> socketIds; std::set<std::string> socketIds;
CpuInfoParser cpuInfoParser{ CpuInfoParser cpuInfoParser{{
{ {"physical id",
{"physical id", [&](const std::string& value) { socketIds.insert(value); }}, [&](const std::string& value) {
}, socketIds.insert(value);
[]() {}}; }},
},
[]() {
}};
cpuInfoParser.run(); cpuInfoParser.run();
// On ARM64, the "physical id" field is unpopulated, causing there to be 0 sockets found. In // On ARM64, the "physical id" field is unpopulated, causing there to be 0 sockets found. In
@ -572,25 +580,61 @@ public:
procCount = 0; procCount = 0;
CpuInfoParser cpuInfoParser{ CpuInfoParser cpuInfoParser{{
{
#ifdef __s390x__ #ifdef __s390x__
{R"re(processor\s+\d+)re", [&](const std::string& value) { procCount++; }}, {R"re(processor\s+\d+)re",
{"cpu MHz static", [&](const std::string& value) { freq = value; }}, [&](const std::string& value) {
{"features", [&](const std::string& value) { features = value; }}, procCount++;
}},
{"cpu MHz static",
[&](const std::string& value) {
freq = value;
}},
{"features",
[&](const std::string& value) {
features = value;
}},
#else #else
{"processor", [&](const std::string& value) { procCount++; }}, {"processor",
{"model name", [&](const std::string& value) { modelString = value; }}, [&](const std::string& value) {
{"cpu MHz", [&](const std::string& value) { freq = value; }}, procCount++;
{"flags", [&](const std::string& value) { features = value; }}, }},
{"CPU implementer", [&](const std::string& value) { cpuImplementer = value; }}, {"model name",
{"CPU architecture", [&](const std::string& value) { cpuArchitecture = value; }}, [&](const std::string& value) {
{"CPU variant", [&](const std::string& value) { cpuVariant = value; }}, modelString = value;
{"CPU part", [&](const std::string& value) { cpuPart = value; }}, }},
{"CPU revision", [&](const std::string& value) { cpuRevision = value; }}, {"cpu MHz",
[&](const std::string& value) {
freq = value;
}},
{"flags",
[&](const std::string& value) {
features = value;
}},
{"CPU implementer",
[&](const std::string& value) {
cpuImplementer = value;
}},
{"CPU architecture",
[&](const std::string& value) {
cpuArchitecture = value;
}},
{"CPU variant",
[&](const std::string& value) {
cpuVariant = value;
}},
{"CPU part",
[&](const std::string& value) {
cpuPart = value;
}},
{"CPU revision",
[&](const std::string& value) {
cpuRevision = value;
}},
#endif #endif
}, },
[]() {}}; []() {
}};
cpuInfoParser.run(); cpuInfoParser.run();
} }

View File

@ -234,7 +234,7 @@ private:
__VA_ARGS__(name##CB{}); \ __VA_ARGS__(name##CB{}); \
} \ } \
template <typename Helper> \ template <typename Helper> \
void name##CB::operator()(Helper&& helper) void name##CB::operator()(Helper && helper)
PRODUCER_CONSUMER_QUEUE_TEST(basicPushPop, runPermutations<false, false>) { PRODUCER_CONSUMER_QUEUE_TEST(basicPushPop, runPermutations<false, false>) {
typename Helper::template ProducerConsumerQueue<MoveOnly> pcq{}; typename Helper::template ProducerConsumerQueue<MoveOnly> pcq{};

View File

@ -728,7 +728,9 @@ TEST_F(PrintAllThreadStacksTest, SessionBasic) {
stacktrace_details::PrintAllStacksSession session; stacktrace_details::PrintAllStacksSession session;
auto waiter = boost::make_optional(session.waiter()); auto waiter = boost::make_optional(session.waiter());
stdx::thread producer{[&] { auto notifier = session.notifier(); }}; stdx::thread producer{[&] {
auto notifier = session.notifier();
}};
waiter = {}; waiter = {};
producer.join(); producer.join();
} }

View File

@ -65,7 +65,9 @@ ProfilerTag ProfilerTags::getOrInsertTag(StringData name) {
size_t CallTree::ChildrenMap::size() const { size_t CallTree::ChildrenMap::size() const {
return std::visit( return std::visit(
OverloadedVisitor{[](const ChildrenInlinedMap& map) -> size_t { return map.size; }, OverloadedVisitor{[](const ChildrenInlinedMap& map) -> size_t { return map.size; },
[](const ChildrenHashMap& map) -> size_t { return map.size(); }}, [](const ChildrenHashMap& map) -> size_t {
return map.size();
}},
*this); *this);
} }

View File

@ -48,7 +48,9 @@ CallTree::ChildrenHashMap getChildren(const CallTree::Node& node) {
} }
return r; return r;
}, },
[](const CallTree::ChildrenHashMap& map) { return map; }}, [](const CallTree::ChildrenHashMap& map) {
return map;
}},
node.children); node.children);
} }

View File

@ -220,7 +220,8 @@ public:
#if __has_feature(thread_sanitizer) #if __has_feature(thread_sanitizer)
__attribute__((no_sanitize("thread"))) __attribute__((no_sanitize("thread")))
#endif #endif
void setSignalOnCount(int c) { void
setSignalOnCount(int c) {
_wait = c; _wait = c;
} }