[SERVER-24275] enableBSON1_1 server parameter doesn't control whether KeyString v1 index is built or not Created: 24/May/16  Updated: 06/Jun/16  Resolved: 25/May/16

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

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:
  1. Start version 3.3.6 of mongod with --setParameter="enableBSON1_1=false".
  2. Shut down the mongod.
  3. Start version 3.2.6 of mongod on the same data directory.

2016-05-24T12:52:02.153-0400 I -        [initandlisten] Fatal assertion 28579 UnsupportedFormat: Application metadata for table:index-1--6305025376839485705 has unsupported format version 7
2016-05-24T12:52:02.153-0400 I -        [initandlisten] 
 
***aborting after fassert() failure

Sprint: Query 15 (06/03/16)
Participants:

 Description   

This prevents testing upgrade/downgrade between MongoDB 3.4 and MongoDB 3.2 without first dropping all collections and indexes that were created in MongoDB 3.4. If KeyString v1 is supposed to be separate from BSON 1.1 (i.e. the decimal data type), then having an additional server parameter to configure kCurrentIndexVersion seems desirable.

One idea for patching this issue

diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index c0b04a4..7a2ef04 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -82,14 +82,10 @@ static const int TempKeyMaxSize = 1024;  // this goes away with SERVER-3372
 
 static const WiredTigerItem emptyItem(NULL, 0);
 
+static const int kKeyStringV0Version = 6;
 static const int kKeyStringV1Version = 7;
-static const int kMinimumIndexVersion = 6;
-static const int kCurrentIndexVersion = kKeyStringV1Version;  // New indexes use this by default.
+static const int kMinimumIndexVersion = kKeyStringV0Version;
 static const int kMaximumIndexVersion = kKeyStringV1Version;
-static_assert(kCurrentIndexVersion >= kMinimumIndexVersion,
-              "kCurrentIndexVersion >= kMinimumIndexVersion");
-static_assert(kCurrentIndexVersion <= kMaximumIndexVersion,
-              "kCurrentIndexVersion <= kMaximumIndexVersion");
 
 bool hasFieldNames(const BSONObj& obj) {
     BSONForEach(e, obj) {
@@ -198,7 +194,7 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(const std::string&
 
     // Index metadata
     ss << ",app_metadata=("
-       << "formatVersion=" << (enableBSON1_1 ? kKeyStringV1Version : kCurrentIndexVersion) << ','
+       << "formatVersion=" << (enableBSON1_1 ? kKeyStringV1Version : kKeyStringV0Version) << ','
        << "infoObj=" << desc.infoObj().jsonString() << "),";
 
     LOG(3) << "index create string: " << ss.ss.str();



 Comments   
Comment by Githook User [ 25/May/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-24275 Use enableBSON1_1 parameter to control KeyString version.

If the "enableBSON1_1" server paramter is set to true, then KeyString v1
is used for newly created indexes on the wiredTiger storage engine.

Otherwise, if the "enableBSON1_1" server parameter is set to false, then
KeyString v0 is used for newly created indexes on the wiredTiger storage
engine.
Branch: master
https://github.com/mongodb/mongo/commit/5d7d8f7d35319c20aaaf53411a5050e07dbaa2ed

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