diff options
author | Mathias Stearn <redbeard0531@gmail.com> | 2014-09-23 17:11:05 -0400 |
---|---|---|
committer | Mathias Stearn <redbeard0531@gmail.com> | 2014-09-24 16:13:59 -0400 |
commit | d80e60ba69909ff6131da82674c6c9e788b28e4d (patch) | |
tree | b88b5de806336d3391a6f6f9957aa3668b7f7e9d | |
parent | e9cc37d2b51cc63e907be8d76be5feff08113b35 (diff) | |
download | mongo-d80e60ba69909ff6131da82674c6c9e788b28e4d.tar.gz |
SERVER-15319 Handle 2.8-style freelist bit in pdfile version
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/db.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/pdfile_version.h | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/data_file.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/storage/data_file.h | 14 |
5 files changed, 29 insertions, 13 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index ead9dd9311e..8614c368f91 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -182,13 +182,8 @@ namespace mongo { bool IndexCatalog::_shouldOverridePlugin(const BSONObj& keyPattern) const { string pluginName = IndexNames::findPluginName(keyPattern); bool known = IndexNames::isKnownName(pluginName); - - int majorVersion; - int minorVersion; - - _collection->_database->getFileFormat( &majorVersion, &minorVersion ); - if (minorVersion == PDFILE_VERSION_MINOR_24_AND_NEWER) { + if (_collection->_database->getExtentManager().getFile(0)->getHeader()->is24IndexClean()) { // RulesFor24 // This assert will be triggered when downgrading from a future version that // supports an index plugin unsupported by this version. @@ -236,11 +231,11 @@ namespace mongo { Database* db = _collection->_database; DataFileHeader* dfh = db->getExtentManager().getFile(0)->getHeader(); - if ( dfh->versionMinor == PDFILE_VERSION_MINOR_24_AND_NEWER ) { + if ( dfh->is24IndexClean() ) { return Status::OK(); // these checks have already been done } - fassert(16737, dfh->versionMinor == PDFILE_VERSION_MINOR_22_AND_OLDER); + fassert(16737, dfh->isCurrentVersion()); auto_ptr<Runner> runner( InternalPlanner::collectionScan( db->_indexesName ) ); @@ -265,7 +260,7 @@ namespace mongo { warning() << "Internal error while reading system.indexes collection"; } - getDur().writingInt(dfh->versionMinor) = PDFILE_VERSION_MINOR_24_AND_NEWER; + dfh->setIs24IndexClean(); return Status::OK(); } diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 69e0076d0a3..1b28f3004b5 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -420,7 +420,7 @@ namespace mongo { const BSONObj key = index.getObjectField("key"); const string plugin = IndexNames::findPluginName(key); - if (h->versionMinor == PDFILE_VERSION_MINOR_22_AND_OLDER) { + if (!h->is24IndexClean()) { if (IndexNames::existedBefore24(plugin)) continue; diff --git a/src/mongo/db/pdfile_version.h b/src/mongo/db/pdfile_version.h index a83b24cf493..c285a8b0d6c 100644 --- a/src/mongo/db/pdfile_version.h +++ b/src/mongo/db/pdfile_version.h @@ -35,6 +35,9 @@ namespace mongo { const int PDFILE_VERSION_MINOR_22_AND_OLDER = 5; const int PDFILE_VERSION_MINOR_24_AND_NEWER = 6; + const int PDFILE_VERSION_MINOR_INDEX_MASK = 0xf; + const int PDFILE_VERSION_MINOR_28_FREELIST_MASK = (1 << 4); // SERVER-14081 + // For backward compatibility with versions before 2.4.0 all new DBs start // with PDFILE_VERSION_MINOR_22_AND_OLDER and are converted when the first // index using a new plugin is created. See the logic in diff --git a/src/mongo/db/storage/data_file.cpp b/src/mongo/db/storage/data_file.cpp index e365ae6bdcd..04cdd4cd095 100644 --- a/src/mongo/db/storage/data_file.cpp +++ b/src/mongo/db/storage/data_file.cpp @@ -174,6 +174,16 @@ namespace mongo { // ------------------------------------------------------------------------------- + bool DataFileHeader::is24IndexClean() const { + return (versionMinor & PDFILE_VERSION_MINOR_INDEX_MASK) + == PDFILE_VERSION_MINOR_24_AND_NEWER; + } + + void DataFileHeader::setIs24IndexClean() { + getDur().writingInt(versionMinor) = ((versionMinor & ~PDFILE_VERSION_MINOR_INDEX_MASK) + | PDFILE_VERSION_MINOR_24_AND_NEWER); + } + void DataFileHeader::init(int fileno, int filelength, const char* filename) { if ( uninitialized() ) { DEV log() << "datafileheader::init initializing " << filename << " n:" << fileno << endl; diff --git a/src/mongo/db/storage/data_file.h b/src/mongo/db/storage/data_file.h index 6402c63da05..f09fa1e11ba 100644 --- a/src/mongo/db/storage/data_file.h +++ b/src/mongo/db/storage/data_file.h @@ -69,11 +69,19 @@ namespace mongo { // all of this should move up to the database level bool isCurrentVersion() const { - return version == PDFILE_VERSION && ( versionMinor == PDFILE_VERSION_MINOR_22_AND_OLDER - || versionMinor == PDFILE_VERSION_MINOR_24_AND_NEWER - ); + if (version != PDFILE_VERSION) + return false; + + // Masking off the 2.8 freelist bit since this version of the code is safe to use with + // it. SERVER-15319 + const int minor = versionMinor & ~PDFILE_VERSION_MINOR_28_FREELIST_MASK; + return minor == PDFILE_VERSION_MINOR_22_AND_OLDER + || minor == PDFILE_VERSION_MINOR_24_AND_NEWER; } + bool is24IndexClean() const; + void setIs24IndexClean(); + bool uninitialized() const { return version == 0; } void init(int fileno, int filelength, const char* filename); |