diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-09-20 19:07:55 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-09-20 19:07:55 -0400 |
commit | 96a21e63bfc1a1cdde01c671d0867310c594ea5a (patch) | |
tree | b1efe9798761e01e3b5fa9750042cee8ac9e2448 /src/mongo/db/commands/list_indexes.cpp | |
parent | fb992867f9f277dd949fdce455bb073975737bab (diff) | |
download | mongo-96a21e63bfc1a1cdde01c671d0867310c594ea5a.tar.gz |
SERVER-25725 Kill 3.2 secondaries when featureCompatibilityVersion=3.4.
Creates a v=2 index on the "admin.system.version" collection when the
featureCompatibilityVersion is set to 3.4. The index version of this
index is returned as a decimal value in the "listIndexes" command
response in order to prevent 3.2 secondaries from performing initial
sync from a 3.4 mongod with featureCompatibilityVersion=3.4.
Diffstat (limited to 'src/mongo/db/commands/list_indexes.cpp')
-rw-r--r-- | src/mongo/db/commands/list_indexes.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index a943061a510..53e563ab7bd 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -35,11 +35,13 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/clientcursor.h" #include "mongo/db/commands.h" +#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" #include "mongo/db/exec/queued_data_stage.h" #include "mongo/db/exec/working_set.h" +#include "mongo/db/index/index_descriptor.h" #include "mongo/db/query/cursor_request.h" #include "mongo/db/query/cursor_response.h" #include "mongo/db/query/find_common.h" @@ -162,6 +164,27 @@ public: } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "listIndexes", ns.ns()); + if (ns.ns() == FeatureCompatibilityVersion::kCollection && + indexNames[i] == FeatureCompatibilityVersion::k32IncompatibleIndexName) { + BSONObjBuilder bob; + + for (auto&& indexSpecElem : indexSpec) { + auto indexSpecElemFieldName = indexSpecElem.fieldNameStringData(); + if (indexSpecElemFieldName == IndexDescriptor::kIndexVersionFieldName) { + // Include the index version in the command response as a decimal type + // instead of as a 32-bit integer. This is a new BSON type that isn't + // supported by versions of MongoDB earlier than 3.4 that will cause 3.2 + // secondaries to crash when performing initial sync. + bob.append(IndexDescriptor::kIndexVersionFieldName, + indexSpecElem.numberDecimal()); + } else { + bob.append(indexSpecElem); + } + } + + indexSpec = bob.obj(); + } + WorkingSetID id = ws->allocate(); WorkingSetMember* member = ws->get(id); member->keyData.clear(); |