diff --git a/tools/rebuildEM/main.cpp b/tools/rebuildEM/main.cpp index 2dc187fc5..3b82843e4 100644 --- a/tools/rebuildEM/main.cpp +++ b/tools/rebuildEM/main.cpp @@ -89,8 +89,7 @@ int main(int argc, char** argv) std::cout << "The launch of mcsRebuildEM tool must be sanctioned by MariaDB support. " << std::endl; std::cout << "Requirement: all DBRoots must be on this node. " << std::endl; - std::cout << "Note: that the launch can break the cluster." << std::endl; - std::cout << "Do you want to continue Y/N? " << std::endl; + std::cout << "Do you want to continue Y/N? "; std::string confirmation; cin >> confirmation; if (confirmation.size() == 0) @@ -124,6 +123,7 @@ int main(int argc, char** argv) std::cout << "If `BRM_saves_em` " "exists extent map will be restored from it. " << std::endl; + std::cout << "Exiting. " << std::endl; return 0; } @@ -131,6 +131,8 @@ int main(int argc, char** argv) auto rc = emReBuilder.initializeSystemExtents(); if (rc == -1) { + std::cerr << "Cannot initialize system extents from binary blob." << std::endl; + std::cerr << "Exiting. " << std::endl; return 1; } @@ -151,5 +153,8 @@ int main(int argc, char** argv) emReBuilder.clear(); } + // Save restored extent map. + emReBuilder.getEM().save(BRMSavesEM); + std::cout << "Completed." << std::endl; return 0; } diff --git a/tools/rebuildEM/rebuildEM.cpp b/tools/rebuildEM/rebuildEM.cpp index cb0d20b40..d74e7a942 100644 --- a/tools/rebuildEM/rebuildEM.cpp +++ b/tools/rebuildEM/rebuildEM.cpp @@ -65,9 +65,7 @@ int32_t EMReBuilder::collectExtent(const std::string& fullFileName) auto rc = WriteEngine::Convertor::fileName2Oid(fullFileName, oid, partition, segment); if (rc != 0) - { return rc; - } // Open the given file. std::unique_ptr dbFile(IDBDataFile::open( @@ -97,12 +95,11 @@ int32_t EMReBuilder::collectExtent(const std::string& fullFileName) // have a header block, so header verification fails in this case, // currently we skip it, because we cannot deduce needed data to create // a column extent from the blob file. - if (doVerbose()) + // Skip fileID from system catalog. + if (doVerbose() && oid > 3000) { - std::cerr - << "Cannot read file header from the file " << fullFileName - << ", probably this file was created without compression. " - << std::endl; + std::cerr << "Cannot read file header from the file " << fullFileName + << ", probably this file was created without compression. " << std::endl; } return rc; } @@ -138,9 +135,8 @@ int32_t EMReBuilder::collectExtent(const std::string& fullFileName) if (colDataType == execplan::CalpontSystemCatalog::UNDEFINED) { if (doVerbose()) - { std::cout << "File header has invalid data. " << std::endl; - } + return -1; } @@ -158,14 +154,10 @@ int32_t EMReBuilder::collectExtent(const std::string& fullFileName) rc = searchHWMInSegmentFile(oid, getDBRoot(), partition, segment, colDataType, colWidth, blockCount, isDict, compressionType, hwm); if (rc != 0) - { return rc; - } if (doVerbose()) - { std::cout << "HWM is: " << hwm << std::endl; - } const uint32_t extentMaxBlockCount = getEM().getExtentRows() * colWidth / BLOCK_SIZE; // We found multiple extents per one segment file. @@ -198,9 +190,7 @@ int32_t EMReBuilder::collectExtent(const std::string& fullFileName) extentMap.push_back(fileId); if (doVerbose()) - { std::cout << "FileId is collected " << fileId << std::endl; - } } return 0;