diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2019-01-22 19:06:07 -0500 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2019-01-31 16:04:51 -0500 |
commit | 97fb96739e7a7defee501e57d9ec38a22b94c3b7 (patch) | |
tree | 8d2e8f95ae211638f56071521f0b9b5f34a0930b | |
parent | df5a4fa9b8d946addfb87484c826773ea19b046e (diff) | |
download | mongo-97fb96739e7a7defee501e57d9ec38a22b94c3b7.tar.gz |
SERVER-38793 Collection with collator sets isNonRepairableFeatureInUse
-rw-r--r-- | jstests/multiVersion/collation_downgrade.js | 14 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/kv_database_catalog_entry.cpp | 3 |
2 files changed, 13 insertions, 4 deletions
diff --git a/jstests/multiVersion/collation_downgrade.js b/jstests/multiVersion/collation_downgrade.js index a4c768d4a86..9a53f2aae23 100644 --- a/jstests/multiVersion/collation_downgrade.js +++ b/jstests/multiVersion/collation_downgrade.js @@ -99,12 +99,20 @@ testDB.dropDatabase(); // We set the featureCompatibilityVersion back to 3.4 in order to use the "collation" option. + // Creating a collection with a non-default collation will set the catalog's + // isNonRepairableFeatureInUse bit, which should prevent a 3.2 mongod process from trying to use + // this catalog at all. Note that we set autoIndexId to false so that we can avoid creating a + // v=2 _id index. A v=2 would also prevent a 3.2 mongod process from using this catalog, but we + // check for that later in this test. assert.commandWorked(conn.getDB("admin").runCommand({setFeatureCompatibilityVersion: "3.4"})); assert.commandWorked( - testDB.createCollection("simplecollator", {collation: {locale: "simple"}})); + testDB.createCollection("nonsimple", {autoIndexId: false, collation: {locale: "fr"}})); - // Downgrade should fail because we have an _id index with v=2 on the "test.simplecollator" - // collection. + // Attempt to downgrade by setting featureCompatibiltyVersion to 3.2 and then shutting down the + // 3.4 mongod and starting up the 3.2 mongod. The 3.2 mongod will accept the + // featureCompatibilityVersion, but it should fail when it sees the isNonRepairableFeatureInUse + // bit. + assert.commandWorked(conn.getDB("admin").runCommand({setFeatureCompatibilityVersion: "3.2"})); MongoRunner.stopMongod(conn); conn = MongoRunner.runMongod(downgradeOptions); assert.eq(null, diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp index 2dd4e000408..4681e1b6668 100644 --- a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp +++ b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp @@ -222,7 +222,8 @@ Status KVDatabaseCatalogEntry::createCollection(OperationContext* txn, // Mark collation feature as in use if the collection has a non-simple default collation. if (!options.collation.isEmpty()) { const auto feature = KVCatalog::FeatureTracker::NonRepairableFeature::kCollation; - if (_engine->getCatalog()->getFeatureTracker()->isNonRepairableFeatureInUse(txn, feature)) { + if (!_engine->getCatalog()->getFeatureTracker()->isNonRepairableFeatureInUse(txn, + feature)) { _engine->getCatalog()->getFeatureTracker()->markNonRepairableFeatureAsInUse(txn, feature); } |