Skip to content
Snippets Groups Projects
Commit 60c40c06 authored by Jorge Camarero Vera's avatar Jorge Camarero Vera
Browse files

Schema verify return 2 if it fails and the schema is upgrading

parent 8300b70d
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
- cta/CTA#950 - Eliminate race condition preventing the drive to go down on failure
- cta/CTA#1160 - Fix DrainingToDisk stale status in case if there is DiskWriteThreadPool thread left
- cta/operations#708 - Fix "Should run cleaner but VID is missing. Putting the drive down"
- cta/CTA#1197 - Return code from `cta-catalogue-schema-verify` should indicate if the schema is in UPGRADING state
### Building and Packaging
### Catalogue Schema
......
......@@ -87,6 +87,10 @@ int VerifySchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar
result += schemaChecker->warnErrorLoggingTables();
result += schemaChecker->warnMissingIndexes();
result.displayWarnings(std::cout);
if(result.getStatus() == SchemaCheckerResult::Status::FAILED
&& isUpgrading(&conn)) {
return 2;
}
if(result.getStatus() == SchemaCheckerResult::Status::FAILED){
return 1;
}
......@@ -113,5 +117,21 @@ void VerifySchemaCmd::printUsage(std::ostream &os) {
VerifySchemaCmdLineArgs::printUsage(os);
}
bool VerifySchemaCmd::isUpgrading(rdbms::Conn *conn) {
const char *const sql =
"SELECT "
"CTA_CATALOGUE.STATUS AS STATUS "
"FROM "
"CTA_CATALOGUE";
auto stmt = conn->createStmt(sql);
auto rset = stmt.executeQuery();
if(!rset.next()) {
throw exception::Exception("CTA_CATALOGUE does not contain any STATUS");
}
return rset.columnString("STATUS") == "UPGRADING";
}
} // namespace catalogue
} // namespace cta
......@@ -74,6 +74,14 @@ private:
* @return True if the table exists.
*/
bool tableExists(const std::string tableName, rdbms::Conn &conn) const;
/*
* Returns true if the catalogue is upgrading
*
* @param conn The database connection
* @return True if the catalogue is upgrading
*/
bool isUpgrading(rdbms::Conn *conn);
#if 0
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment