Commit 0d45021f authored by Michael Davis's avatar Michael Davis
Browse files

[migration] EosInsertMissingDirs doesn't open too many cursors

parent eb263dd0
......@@ -70,8 +70,8 @@ EosInsertMissingDirs::EosInsertMissingDirs(const std::string &configfile) :
// Parse configuration file
XrdSsiPb::Config config(configfile);
auto is_json = config.getOptionValueBool("castor.json");
auto dbconn = config.getOptionValueStr("castor.db_login");
auto is_json = config.getOptionValueBool("castor.json");
auto max_num_conns = config.getOptionValueInt("castor.max_num_connections");
auto batch_size = config.getOptionValueInt("castor.batch_size");
auto min_depth = config.getOptionValueInt("castor.min_depth");
......@@ -127,11 +127,16 @@ void EosInsertMissingDirs::process()
std::cerr << "(" << missingDirs.size() << ")...done." << std::endl;
std::cerr << "Inserting directories into DB...";
int fileid = 2000000598;
m_castordb.query("SELECT MAX(FILEID) AS MAX_FILE_ID FROM CTADIRSHELPER");
uint64_t fileid = m_castordb.getResultColumnUint64("MAX_FILE_ID");
std::cerr << "(" << std::to_string(fileid) << ")...";
int cnt = 0;
for(auto &m : missingDirs) {
m_castordb.execute("INSERT INTO CTADIRSHELPER(FILEID, PATH, DISK_UID, DISK_GID, FILEMODE, BTIME, CTIME, MTIME, CLASSID, PARENT_FILEID, DEPTH) "
"VALUES(" + std::to_string(fileid++) + ",\'" + m.first + "\'," +
"VALUES(" + std::to_string(++fileid) + ",\'" + m.first + "\'," +
"22103,1028,16877,1543833246,1543833247,1543833248,5012,0," + std::to_string(m.second) + ")");
if(++cnt > 1000) { cnt = 0; std::cerr << "."; }
}
std::cerr << "done." << std::endl;
......
......@@ -45,6 +45,7 @@ public:
void execute(const std::string &sqlString) {
auto sql = m_conn.createStmt(sqlString);
sql.executeNonQuery();
sql.getStmt().close();
}
void query(const std::string &sqlString) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment