diff --git a/catalogue/RdbmsArchiveFileItorImpl.cpp b/catalogue/RdbmsArchiveFileItorImpl.cpp index 5460e8a5ec892ddee090ce7a02098ca89c6fee78..e9d3cf49df4320ec9df94e2a22e38d3bfc1d99cf 100644 --- a/catalogue/RdbmsArchiveFileItorImpl.cpp +++ b/catalogue/RdbmsArchiveFileItorImpl.cpp @@ -233,7 +233,7 @@ RdbmsArchiveFileItorImpl::RdbmsArchiveFileItorImpl( if(searchCriteria.tapePool) { m_stmt.bindString(":TAPE_POOL_NAME", searchCriteria.tapePool.value()); } - m_rset = m_stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + m_rset = m_stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); m_rsetIsEmpty = !m_rset.next(); } catch(exception::UserError &) { diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index f41f5ba84ac3f40a4ca17be5456d496824430007..637e01009909cba060a24d6da18e335e534fef74 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -162,7 +162,7 @@ bool RdbmsCatalogue::adminUserExists(rdbms::Conn &conn, const std::string adminU "ADMIN_USER_NAME = :ADMIN_USER_NAME"; auto stmt = conn.createStmt(sql); stmt.bindString(":ADMIN_USER_NAME", adminUsername); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -219,7 +219,7 @@ std::list<common::dataStructures::AdminUser> RdbmsCatalogue::getAdminUsers() con "ADMIN_USER_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::AdminUser admin; @@ -390,7 +390,7 @@ bool RdbmsCatalogue::storageClassExists(rdbms::Conn &conn, const std::string &di auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -457,7 +457,7 @@ std::list<common::dataStructures::StorageClass> RdbmsCatalogue::getStorageClasse "DISK_INSTANCE_NAME, STORAGE_CLASS_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::StorageClass storageClass; @@ -676,7 +676,7 @@ bool RdbmsCatalogue::tapePoolExists(rdbms::Conn &conn, const std::string &tapePo "TAPE_POOL_NAME = :TAPE_POOL_NAME"; auto stmt = conn.createStmt(sql); stmt.bindString(":TAPE_POOL_NAME", tapePoolName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -700,7 +700,7 @@ bool RdbmsCatalogue::archiveFileIdExists(rdbms::Conn &conn, const uint64_t archi "ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID"; auto stmt = conn.createStmt(sql); stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -728,7 +728,7 @@ bool RdbmsCatalogue::diskFileIdExists(rdbms::Conn &conn, const std::string &disk auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_ID", diskFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -756,7 +756,7 @@ bool RdbmsCatalogue::diskFilePathExists(rdbms::Conn &conn, const std::string &di auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_PATH", diskFilePath); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -784,7 +784,7 @@ bool RdbmsCatalogue::diskFileUserExists(rdbms::Conn &conn, const std::string &di auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_USER", diskFileUser); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -812,7 +812,7 @@ bool RdbmsCatalogue::diskFileGroupExists(rdbms::Conn &conn, const std::string &d auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_GROUP", diskFileGroup); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -844,7 +844,7 @@ bool RdbmsCatalogue::archiveRouteExists(rdbms::Conn &conn, const std::string &di stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -924,7 +924,7 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const { auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { TapePool pool; @@ -1301,7 +1301,7 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes "DISK_INSTANCE_NAME, STORAGE_CLASS_NAME, COPY_NB"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::ArchiveRoute route; @@ -1503,7 +1503,7 @@ bool RdbmsCatalogue::logicalLibraryExists(rdbms::Conn &conn, const std::string & "LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME"; auto stmt = conn.createStmt(sql); stmt.bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -1560,7 +1560,7 @@ std::list<common::dataStructures::LogicalLibrary> RdbmsCatalogue::getLogicalLibr "LOGICAL_LIBRARY_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::LogicalLibrary lib; @@ -1782,7 +1782,7 @@ bool RdbmsCatalogue::tapeExists(rdbms::Conn &conn, const std::string &vid) const "VID = :VID"; auto stmt = conn.createStmt(sql); stmt.bindString(":VID", vid); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -1967,7 +1967,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co if(searchCriteria.full) stmt.bindBool(":IS_FULL", searchCriteria.full.value()); if(searchCriteria.lbp) stmt.bindBool(":LBP_IS_ON", searchCriteria.lbp.value()); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::Tape tape; @@ -2070,6 +2070,9 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); + // The following should be replaced by an insert into a temporrary table + // because this code can create many different prepared statements when + // there should only be one { uint64_t vidNb = 1; for(auto &vid : vids) { @@ -2078,7 +2081,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se } } - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::Tape tape; @@ -2172,7 +2175,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const { auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::Tape tape; @@ -3058,7 +3061,7 @@ std::list<common::dataStructures::RequesterMountRule> RdbmsCatalogue::getRequest "DISK_INSTANCE_NAME, REQUESTER_NAME, MOUNT_POLICY_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while(rset.next()) { common::dataStructures::RequesterMountRule rule; @@ -3252,7 +3255,7 @@ optional<common::dataStructures::MountPolicy> RdbmsCatalogue::getRequesterGroupM auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", group.diskInstanceName); stmt.bindString(":REQUESTER_GROUP_NAME", group.groupName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); if(rset.next()) { common::dataStructures::MountPolicy policy; @@ -3313,7 +3316,7 @@ std::list<common::dataStructures::RequesterGroupMountRule> RdbmsCatalogue::getRe "DISK_INSTANCE_NAME, REQUESTER_GROUP_NAME, MOUNT_POLICY_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while(rset.next()) { common::dataStructures::RequesterGroupMountRule rule; @@ -3385,7 +3388,7 @@ bool RdbmsCatalogue::mountPolicyExists(rdbms::Conn &conn, const std::string &mou "MOUNT_POLICY_NAME = :MOUNT_POLICY_NAME"; auto stmt = conn.createStmt(sql); stmt.bindString(":MOUNT_POLICY_NAME", mountPolicyName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -3412,7 +3415,7 @@ bool RdbmsCatalogue::requesterMountRuleExists(rdbms::Conn &conn, const std::stri auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":REQUESTER_NAME", requesterName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -3479,7 +3482,7 @@ optional<common::dataStructures::MountPolicy> RdbmsCatalogue::getRequesterMountP auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", user.diskInstanceName); stmt.bindString(":REQUESTER_NAME", user.username); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); if(rset.next()) { common::dataStructures::MountPolicy policy; @@ -3534,7 +3537,7 @@ bool RdbmsCatalogue::requesterGroupMountRuleExists(rdbms::Conn &conn, const std: auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":REQUESTER_GROUP_NAME", requesterGroupName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -3599,7 +3602,7 @@ std::list<common::dataStructures::MountPolicy> RdbmsCatalogue::getMountPolicies( "MOUNT_POLICY_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { common::dataStructures::MountPolicy policy; @@ -4068,7 +4071,7 @@ std::list<common::dataStructures::ArchiveFile> RdbmsCatalogue::getFilesForRepack auto stmt = conn.createStmt(sql); stmt.bindString(":VID", vid); stmt.bindUint64(":START_FSEQ", startFSeq); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); std::list<common::dataStructures::ArchiveFile> archiveFiles; while(rset.next()) { @@ -4230,7 +4233,7 @@ common::dataStructures::ArchiveFileSummary RdbmsCatalogue::getTapeFileSummary( if(searchCriteria.tapePool) { stmt.bindString(":TAPE_POOL_NAME", searchCriteria.tapePool.value()); } - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); if(!rset.next()) { throw exception::Exception("SELECT COUNT statement did not returned a row"); } @@ -4443,7 +4446,7 @@ common::dataStructures::TapeCopyToPoolMap RdbmsCatalogue::getTapeCopyToPoolMap(r auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", storageClass.diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClass.storageClassName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { const uint64_t copyNb = rset.columnUint64("COPY_NB"); const std::string tapePoolName = rset.columnString("TAPE_POOL_NAME"); @@ -4497,7 +4500,7 @@ uint64_t RdbmsCatalogue::getExpectedNbArchiveRoutes(rdbms::Conn &conn, const Sto auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", storageClass.diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClass.storageClassName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); if(!rset.next()) { throw exception::Exception("Result set of SELECT COUNT(*) is empty"); } @@ -4679,7 +4682,7 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies( stmt.bindString(":GROUP_DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":REQUESTER_NAME", requesterName); stmt.bindString(":REQUESTER_GROUP_NAME", requesterGroupName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); RequesterAndGroupMountPolicies policies; while(rset.next()) { @@ -4955,7 +4958,7 @@ bool RdbmsCatalogue::isNonCachedAdmin(const common::dataStructures::SecurityIden auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); stmt.bindString(":ADMIN_USER_NAME", admin.username); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); return rset.next(); } catch(exception::UserError &) { throw; @@ -4996,7 +4999,7 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string & auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); stmt.bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); while (rset.next()) { TapeForWriting tape; tape.vid = rset.columnString("VID"); @@ -5110,7 +5113,7 @@ uint64_t RdbmsCatalogue::getTapeLastFSeq(rdbms::Conn &conn, const std::string &v "VID = :VID"; auto stmt = conn.createStmt(sql); stmt.bindString(":VID", vid); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); if(rset.next()) { return rset.columnUint64("LAST_FSEQ"); } else { @@ -5164,7 +5167,7 @@ std::unique_ptr<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveF "TAPE_FILE.CREATION_TIME ASC"; auto stmt = conn.createStmt(sql); stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile; while (rset.next()) { if(nullptr == archiveFile.get()) { @@ -5253,7 +5256,7 @@ std::unique_ptr<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveF "TAPE_FILE.CREATION_TIME ASC"; auto stmt = conn.createStmt(sql); stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile; while (rset.next()) { if(nullptr == archiveFile.get()) { @@ -5343,7 +5346,7 @@ std::unique_ptr<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveF auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_ID", diskFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile; while (rset.next()) { if(nullptr == archiveFile.get()) { @@ -5436,7 +5439,7 @@ std::unique_ptr<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveF auto stmt = conn.createStmt(sql); stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":DISK_FILE_ID", diskFileId); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile; while (rset.next()) { if(nullptr == archiveFile.get()) { @@ -5491,7 +5494,7 @@ void RdbmsCatalogue::ping() { const char *const sql = "SELECT COUNT(*) FROM CTA_CATALOGUE"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); } catch(exception::UserError &) { throw; } catch(exception::Exception &ex) { diff --git a/cmake/Findmysql.cmake b/cmake/Findmysql.cmake index cbd79629f2fe9a444af7b372d2177fb687f6118b..ae7784c554d99da3232ebf8c1f5b00698e94f266 100644 --- a/cmake/Findmysql.cmake +++ b/cmake/Findmysql.cmake @@ -26,7 +26,7 @@ find_path(MYSQL_INCLUDE_DIRS find_library(MYSQL_LIBRARIES NAME mysqlclient - PATHS /usr/lib64/mysql/ + PATHS /usr/lib64/mysql /usr/lib64 NO_DEFAULT_PATH) message (STATUS "MYSQL_INCLUDE_DIRS = ${MYSQL_INCLUDE_DIRS}") diff --git a/cmdline/CMakeLists.txt b/cmdline/CMakeLists.txt index adad349308206b740bc6a8ee2f9855932b35afda..01eb4f7388ac038549e31189bbe9adbbe3676835 100644 --- a/cmdline/CMakeLists.txt +++ b/cmdline/CMakeLists.txt @@ -48,6 +48,7 @@ target_link_libraries(cta-wfe-test cryptopp ctacommon XrdSsiPbEosCta XrdSsi-4 Xr set_property (TARGET cta-wfe-test APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) install(TARGETS cta-admin DESTINATION usr/bin) +install(FILES cta-admin.1cta DESTINATION usr/share/man/man1) install(TARGETS cta-wfe-test DESTINATION usr/bin) install(FILES cta-cli.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta) diff --git a/cmdline/cta-admin.1cta b/cmdline/cta-admin.1cta new file mode 100644 index 0000000000000000000000000000000000000000..68f4c5dbeec816ff94a29dbc3009322a528f9816 --- /dev/null +++ b/cmdline/cta-admin.1cta @@ -0,0 +1,173 @@ +.\" Manpage for cta-admin +.TH cta-admin 1cta "January 2019" "0.1" "The CERN Tape Archive (CTA)" +.SH NAME +cta-admin \- administrative command interface for tape system operators +.SH SYNOPSIS +cta-admin [--json] \fIcommand\fR [\fIsubcommand\fR] [\fIoptions\fR] +.P +cta-admin sends the specified command to the CTA Frontend (see \fBCONFIGURATION FILE\fR below). +.P +Commands which return a list of results from the server display on stdout. +.SH DESCRIPTION +Invoking cta-admin with no command line parameters shows a list of valid commands. +.P +To show the subcommands and options for a specific command, type: + cta-admin \fIcommand\fR help +.SS Options +.TP +--json +Some commands, such as \fBcta-admin archivefile ls\fR, can return an arbitrarily long list of results, +which are normally returned in plain text format, with one record per line. If the --json option is +supplied, the results are returned as an array of records in JSON format. This option is intended for +use by scripts to ease automated processing of results. +.SS Commands +Commands have a long version and an abbreviated version (shown in brackets). +.TP +admin (ad) +Add, change, remove or list the administrators of the system. In order to use cta-admin, users must +exist in the administrator list and must authenticate themselves with a valid Kerberos KRB5 credential. +.TP +archivefile (af) +List files which have been archived to tape. +.TP +archiveroute (ar) +Add, change, remove or list the archive routes, which are the policies linking namespace entries to +tapepools. +.TP +drive (dr) +Bring tape drives up or down, list tape drives or remove tape drives from the CTA system. +.TP +groupmountrule (gmr) +Add, change, remove or list the group mount rules. +.TP +listpendingarchives (lpa) +List pending archive requests. +.TP +listpendingretrieves (lpr) +List pending retrieve requests. +.TP +logicallibrary (ll) +Add, change, remove or list the logical libraries, which are logical groupings of tapes and drives based +on physical location and tape drive capabilities. A tape can be accessed by a drive if it is in the same +physical library and if the drive is capable of reading or writing the tape. In this case, that tape and +that drive should normally also be in the same logical library. +.TP +mountpolicy (mp) +Add, change, remove or list the mount policies. +.TP +repack (re) +Manage tape repacking. +.TP +requestermountrule (rmr) +Add, change, remove or list the requester mount rules. +.TP +showqueues (sq) +Show the status of all active queues. +.TP +shrink (sh) +Shrink a tapepool. +.TP +storageclass (sc) +Add, change, remove or list the storage classes. Storage classes are associated with directories, to +specify the number of tape copies the files in the directory should have. Storage classes should be +changed only rarely. +.TP +tape (ta) +Add, change, remove, reclaim, list or label tapes. This command is used to manage the physical tape +cartridges in each library. +.TP +tapepool (tp) +Add, change, remove or list the tapepools, which are logical sets of tapes. Tapepools are used to manage +the life cycle of tapes (label → supply → user pool → erase → label). Listing the tapepools shows +statistics such as the total number of tapes in the pool, number of free tapes, etc. +.TP +test (te) +Test tape read/writes. This is a synchronous command that returns performance stats and errors. It +should be run on an empty self-dedicated drive. +.TP +verify (ve) +Manage tape verification. +.SH CONFIGURATION FILE +The cta-admin configuration is specified in \fI/etc/cta/cta-cli.conf\fR. The following configuration +options are available: +.TP +cta.endpoint (mandatory) +Specifies the CTA Frontend hostname (FQDN) and TCP port. +.TP +cta.resource.options (default: \fInone\fR) +Currently the only supported option is \fIReusable\fR. For an explanation of XRootD SSI reusable resources, see: + \fIhttp://xrootd.org/doc/dev49/ssi_reference-V2.htm#_Toc506323429\fR +.TP +cta.log (default: \fInone\fR) +Sets the client log level (see \fBXrdSsiPbLogLevel\fR below). +.TP +cta.log.hiRes (default: \fIfalse\fR) +Specify whether log timestamps should have second (\fIfalse\fR) or microsecond (\fItrue\fR) resolution. +.SS Example configuration file + cta.endpoint cta-frontend.cern.ch:10955 + cta.resource.options Reusable +.SH ENVIRONMENT VARIABLES +.TP +XrdSecPROTOCOL +Sets the XRootD security protocol to use for client/server connections. Note that the CTA Frontend enforces +the use of the \fIkrb5\fR protocol. Admin commands sent using a different security protocol will be rejected. +.TP +XrdSsiPbLogLevel +Set the desired log level (default: \fInone\fR). Logging is sent to stderr. + +Available log levels are: \fInone\fR \fIerror\fR \fIwarning\fR \fIinfo\fR \fIdebug\fR + +There are two additional debugging flags to expose details of the communication between client and server: + \fIprotobuf\fR shows the contents of the Google Protocol buffers used for communication in JSON format + \fIprotoraw\fR shows the serialized Google Protocol buffer, i.e. the binary format sent on the wire + +Log level \fIall\fR is a synonym for "\fIdebug\fR \fIprotobuf\fR \fIprotoraw\fR". +.TP +XRDDEBUG +If the XRootD environment variable XRDDEBUG=1, the log level is set to \fIall\fR (see above). +.TP +XRD_REQUESTTIMEOUT (default: \fI1800\fR seconds) +Sets a limit on the time for the entire request to be processed: connection to load balancer + +redirection + connection to data server + request/response round-trip. Normally this should be less than +one second, but for a heavily-loaded system can take more than one minute. + +The same timeout is also applied to the response for list commands. List commands can return arbitrarily +long output, but by using the XRootD SSI stream mechanism, the timeout is applied to each packet of the +response rather than the total time taken to process the response. +.TP +XRD_STREAMTIMEOUT +Note that the XRootD stream timeout is explicitly disabled by the XRootD server for SSI requests, so this +environment variable is \fBnot\fR used. +.TP +XRD_CONNECTIONRETRY (default: \fI1\fR) +By default, if the connection to the CTA Frontend fails for any reason, cta-admin returns immediately with +\fB[FATAL] Connection error\fR. XRD_CONNECTIONRETRY and XRD_CONNECTIONWINDOW can be used to configure +retry behaviour. Note that Connection Retry is a misnomer as it sets the total number of attempts, not the +number of retries. +.\" .SH EXAMPLES +.\" Some examples of common usage. +.SH SEE ALSO +CTA Administrators' Guide \fIhttps://gitlab.cern.ch/cta/CTA/blob/master/doc/CTA_Admin.pdf\fR +.\" cta-objectstore-list(1), cta-objectstore-dump-object(1) +.SH KNOWN BUGS +The --json option only works for commands which have been implemented as XRootD SSI streams. This is +not currently the case for all list commands. +.P +When using the --json option, 64-bit integer fields are returned as strings. This is a feature of the +Google Protocol Buffers library, to cope with the fact that JavaScript parsers do not have the ability +to handle integers with more than 32-bit precision. +.SH AUTHOR +Michael Davis (\fImichael.davis@cern.ch\fR) +.SH COPYRIGHT +This program is part of the CERN Tape Archive (CTA). Copyright © 2019 CERN. +.P +This program is free software: you can redistribute it and/or modify it under the terms of the GNU +General Public License as published by the Free Software Foundation, either version 3 of the License, +or (at your option) any later version. +.P +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +License for more details. +.P +You should have received a copy of the GNU General Public License along with this program. If not, see +\fIhttp://www.gnu.org/licenses/\fR. diff --git a/common/Configuration.cpp b/common/Configuration.cpp index 58756c945c666357c1ec6ef6be213c173c94cd0d..b5c9c3ee2e71876c101e5f806c47b1b128f8096d 100644 --- a/common/Configuration.cpp +++ b/common/Configuration.cpp @@ -134,7 +134,7 @@ const std::string& cta::common::Configuration::getConfEntString( } // Unlock and return default pthread_rwlock_unlock(&m_lock); - } catch (cta::exception::Exception ex) { + } catch (cta::exception::Exception) { // exception caught : Unlock and return default pthread_rwlock_unlock(&m_lock); // log the exception diff --git a/continuousintegration/docker/ctafrontend/cc7/config/ctaeos/etc/xrd.cf.mgm b/continuousintegration/docker/ctafrontend/cc7/config/ctaeos/etc/xrd.cf.mgm index fc7fd2b9f6e882b4c378bd75f72c63909b2ef9c4..5cfba50fafc83a0dd3cbd98c0d49448e67aa7daa 100644 --- a/continuousintegration/docker/ctafrontend/cc7/config/ctaeos/etc/xrd.cf.mgm +++ b/continuousintegration/docker/ctafrontend/cc7/config/ctaeos/etc/xrd.cf.mgm @@ -63,3 +63,6 @@ mgmofs.nslib /usr/lib64/libEosNsInMemory.so # Set the endpoint and resources for EOS/CTA Workflows mgmofs.protowfendpoint ctafrontend:10955 mgmofs.protowfresource /ctafrontend + +# Turn on the MGM LRU tape aware garbage collector +mgmofs.tapeawaregc.defaultspace.enable true diff --git a/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list b/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list index ac072cd69926d59d776cf3873d738af6fffc91c3..43efaaeeb9c9dffa7ca3702632f99c1bf9cbd5cd 100644 --- a/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list +++ b/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list @@ -1,17 +1,17 @@ -0:eos-archive-4.4.19-1.el7.cern.x86_64 -0:eos-cleanup-4.4.19-1.el7.cern.x86_64 -0:eos-client-4.4.19-1.el7.cern.x86_64 -0:eos-debuginfo-4.4.19-1.el7.cern.x86_64 -0:eos-fuse-4.4.19-1.el7.cern.x86_64 -0:eos-fuse-core-4.4.19-1.el7.cern.x86_64 -0:eos-fuse-sysv-4.4.19-1.el7.cern.x86_64 -0:eos-fusex-4.4.19-1.el7.cern.x86_64 -0:eos-fusex-core-4.4.19-1.el7.cern.x86_64 -0:eos-fusex-selinux-4.4.19-1.el7.cern.x86_64 -0:eos-server-4.4.19-1.el7.cern.x86_64 -0:eos-srm-4.4.19-1.el7.cern.x86_64 -0:eos-test-4.4.19-1.el7.cern.x86_64 -0:eos-testkeytab-4.4.19-1.el7.cern.x86_64 +0:eos-archive-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-cleanup-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-client-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-debuginfo-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fuse-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fuse-core-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fuse-sysv-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fusex-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fusex-core-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-fusex-selinux-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-server-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-srm-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-test-4.4.19-20190111105204git8c85301.el7.cern.x86_64 +0:eos-testkeytab-4.4.19-20190111105204git8c85301.el7.cern.x86_64 1:python2-xrootd-4.9.0-0.rc1.el7.* 1:python3-xrootd-4.9.0-0.rc1.el7.* 1:xrootd-4.9.0-0.rc1.el7.* diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init_pod.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init_pod.sh index ddbb23a5eb67430fcb16129d55ab7829af0fb8d9..7b1366625b312c7efa06bdbc6995c64628cd9cac 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init_pod.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init_pod.sh @@ -44,7 +44,7 @@ if [[ -n ${BUILDTREE_BASE} ]]; then yum() { echo "Skipping yum $@"; } /opt/run/bin/mkSymlinks.sh - # cta:cta needed for ctafrontend and taped but adding it inconditionally in buildtree + # cta:tape needed for ctafrontend and taped but adding it inconditionally in buildtree echo "Adding cta user and group" /usr/bin/getent passwd cta || /usr/sbin/useradd -s /bin/nologin -c "CTA system account" -g tape cta ## The following is not working as one cannot refresh groups in current shell... diff --git a/continuousintegration/orchestration/tests/archive_retrieve.sh b/continuousintegration/orchestration/tests/archive_retrieve.sh index 1e670cad1095900dbe8911c154a20262befab426..17051363651b00597aee3b27053b783b7d5c23aa 100755 --- a/continuousintegration/orchestration/tests/archive_retrieve.sh +++ b/continuousintegration/orchestration/tests/archive_retrieve.sh @@ -34,7 +34,7 @@ echo echo "Launching simple_client_ar.sh on client pod" echo " Archiving file: xrdcp as user1" echo " Retrieving it as poweruser1" -kubectl -n ${NAMESPACE} cp simple_client_ar.sh client:/root/client_ar.sh +kubectl -n ${NAMESPACE} cp simple_client_ar.sh client:/root/simple_client_ar.sh kubectl -n ${NAMESPACE} cp client_helper.sh client:/root/client_helper.sh kubectl -n ${NAMESPACE} exec client -- bash /root/simple_client_ar.sh || exit 1 diff --git a/continuousintegration/orchestration/tests/client_ar.sh b/continuousintegration/orchestration/tests/client_ar.sh index 1d346d1d547d7137816bc562d53e9e050db1a0d3..b2da24acbc97ece639516d1701c67857ae593202 100644 --- a/continuousintegration/orchestration/tests/client_ar.sh +++ b/continuousintegration/orchestration/tests/client_ar.sh @@ -183,6 +183,36 @@ echo "###" LASTCOUNT=${RETRIEVED} +# Updating all files statuses +# Please note that s/d[^0]::t[^0] now maps to 'retrieved' and not 'archived' as +# in previous status mappings +eos root://${EOSINSTANCE} ls -y ${EOS_DIR} | sed -e 's/^\(d.::t.\).*\(test[0-9]\+\)$/\2 \1/;s/d[^0]::t[^0]/retrieved/;s/d[^0]::t0/copied/;s/d0::t0/error/;s/d0::t[^0]/tapeonly/' > ${STATUS_FILE} + +# The format of the STATUS_FILE is two space separated columns per line. The +# first column is the name of the file and the second is the status of the file. +# For example: +# +# test0000 retrieved +# test0001 retrieved +# test0002 retrieved +# test0003 retrieved + +echo "CHECKING sys.retrieves HAS BEEN RESET FOR EACH RETRIEVED FILE" +for RETRIEVED_FILE in `cat ${STATUS_FILE} | grep retrieved | awk '{print $1;}'`; do + RETRIEVED_FILE_FULL_PATH=${EOS_DIR}/${RETRIEVED_FILE} + + SYS_RETRIEVES_ATTR_GET=`eos root://${EOSINSTANCE} attr get sys.retrieves ${RETRIEVED_FILE_FULL_PATH}` + if ! echo ${SYS_RETRIEVES_ATTR_GET} | egrep -q '^sys.retrieves='; then + die "Failed to get value of sys.retrieves for retrieved file ${RETRIEVED_FILE_FULL_PATH}" + fi + + SYS_RETRIEVES_VALUE=`echo ${SYS_RETRIEVES_ATTR_GET} | tr '"' ' ' | awk '{print $NF;}'` + if test "0" != "${SYS_RETRIEVES_VALUE}"; then + die "ERROR sys.retrieves for ${RETRIEVED_FILE_FULL_PATH} is ${SYS_RETRIEVES_VALUE} when it should have been reset to 0" + fi +done +echo "sys.retrieves HAS BEEN SUCCESSFULLY RESET TO 0 FOR ALL RETRIEVED FILES" + DELETED=0 if [[ $REMOVE == 1 ]]; then echo "Waiting for files to be removed from EOS and tapes" diff --git a/cta.spec.in b/cta.spec.in index 6e199427a26dd97a44d6e0f21cba748bc65ae656..607f8a179666b0d0dd1b0e1f97ab4935bbf8b7cc 100644 --- a/cta.spec.in +++ b/cta.spec.in @@ -218,6 +218,7 @@ The xroot plugin %files -n cta-cli %defattr(-,root,root) %attr(0755,root,root) %{_bindir}/cta-admin +%attr(0644,root,root) %doc /usr/share/man/man1/cta-admin.1cta.gz %attr(0755,root,root) %{_bindir}/cta-wfe-test %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-cli.conf diff --git a/rdbms/wrapper/SqliteStmt.cpp b/rdbms/wrapper/SqliteStmt.cpp index ed59d3d15d0564cfb3df4f468977e39123f4098e..05ca2d7619489aabc9ff9adcaf16c77753428d51 100644 --- a/rdbms/wrapper/SqliteStmt.cpp +++ b/rdbms/wrapper/SqliteStmt.cpp @@ -287,7 +287,7 @@ void SqliteStmt::startDeferredTransactionIfNecessary(const AutocommitMode autoco " AUTOCOMMIT_ON statement. Use commit() between the statements instead"); } - if(m_conn.m_transactionInProgress && !autocommit) { + if(!m_conn.m_transactionInProgress && !autocommit) { beginDeferredTransaction(); m_conn.m_transactionInProgress = true; } diff --git a/rdbms/wrapper/SqliteStmtTest.cpp b/rdbms/wrapper/SqliteStmtTest.cpp index 52b774689ca546c68b002b1f6264747749a559c8..2cd7223bf6ae24c3c8c648866b221076dfc20701 100644 --- a/rdbms/wrapper/SqliteStmtTest.cpp +++ b/rdbms/wrapper/SqliteStmtTest.cpp @@ -53,7 +53,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, create_table) { "WHERE " "TYPE = 'table';"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto nbTables = rset->columnOptionalUint64("NB_TABLES"); ASSERT_TRUE((bool)nbTables); @@ -83,7 +83,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, create_table) { "NAME = 'TEST1' AND " "TYPE = 'table';"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto nbTables = rset->columnOptionalUint64("NB_TABLES"); ASSERT_TRUE((bool)nbTables); @@ -114,7 +114,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, create_table) { "NAME = 'TEST2' AND " "TYPE = 'table';"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto nbTables = rset->columnOptionalUint64("NB_TABLES"); ASSERT_TRUE((bool)nbTables); @@ -162,7 +162,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, select_from_empty_table) { "FROM " "TEST;"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_FALSE(rset->next()); } } @@ -213,7 +213,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, insert_without_bind) { "FROM " "TEST;"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto col1 = rset->columnOptionalString("COL1"); @@ -282,7 +282,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, insert_with_bind) { "FROM " "TEST;"; auto stmt = conn.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto col1 = rset->columnOptionalString("COL1"); @@ -349,7 +349,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, isolated_transaction) { "FROM " "TEST;"; auto stmt = connForSelect.createStmt(sql); - auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF); + auto rset = stmt->executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON); ASSERT_TRUE(rset->next()); const auto nbRows = rset->columnOptionalUint64("NB_ROWS"); diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp index c2cc6874b94194f4f2ec866556ac5f87781470e0..283a92124ed4af19922c0bc3264125e58c36e71c 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp @@ -1692,9 +1692,8 @@ TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullMigration) { // Check logs for drive statistics std::string logToCheck = logger.getLog(); logToCheck += ""; - ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"Tape session started\" thread=\"TapeWrite\" tapeDrive=\"T10D6116\" tapeVid=\"TstVid\" mountId=\"1\" " - "lastFseq=\"0\" compression=\"1\" useLbp=\"0\" vo=\"vo\" " - "mediaType=\"TestMediaType\" tapePool=\"TestTapePool\" logicalLibrary=\"TestLogicalLibrary\" " + ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"Tape session started\" thread=\"TapeWrite\" tapeDrive=\"T10D6116\" tapeVid=\"TstVid\" " + "mountId=\"1\" vo=\"vo\" mediaType=\"TestMediaType\" tapePool=\"TestTapePool\" logicalLibrary=\"TestLogicalLibrary\" " "mountType=\"Archive\" vendor=\"TestVendor\" capacityInBytes=\"12345678\"")); ASSERT_NE(std::string::npos, logToCheck.find("firmwareVersion=\"123A\" serialNumber=\"123456\" " "mountTotalCorrectedWriteErrors=\"5\" mountTotalUncorrectedWriteErrors=\"1\" " diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp index 7b629f1a2ea2913ffed79139decd459ec51ac7df..34fa9934ca4ae936ce3d0a22109ab14f481069f8 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp @@ -177,15 +177,6 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::openReadSession() { try{ std::unique_ptr<castor::tape::tapeFile::ReadSession> rs( new castor::tape::tapeFile::ReadSession(m_drive,m_volInfo, m_useLbp)); - cta::log::ScopedParamContainer params(m_logContext); - params.add("vo",m_retrieveMount.getVo()); - params.add("mediaType",m_retrieveMount.getMediaType()); - params.add("tapePool",m_retrieveMount.getPoolName()); - params.add("logicalLibrary",m_drive.config.logicalLibrary); - params.add("mountType",mountTypeToString(m_volInfo.mountType)); - params.add("vendor",m_retrieveMount.getVendor()); - params.add("capacityInBytes",m_retrieveMount.getCapacityInBytes()); - m_logContext.log(cta::log::INFO, "Tape session started"); //m_logContext.log(cta::log::DEBUG, "Created tapeFile::ReadSession with success"); return rs; @@ -244,6 +235,15 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() { TapeCleaning tapeCleaner(*this, timer); // Before anything, the tape should be mounted m_rrp.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting); + cta::log::ScopedParamContainer params(m_logContext); + params.add("vo",m_retrieveMount.getVo()); + params.add("mediaType",m_retrieveMount.getMediaType()); + params.add("tapePool",m_retrieveMount.getPoolName()); + params.add("logicalLibrary",m_drive.config.logicalLibrary); + params.add("mountType",mountTypeToString(m_volInfo.mountType)); + params.add("vendor",m_retrieveMount.getVendor()); + params.add("capacityInBytes",m_retrieveMount.getCapacityInBytes()); + m_logContext.log(cta::log::INFO, "Tape session started"); mountTapeReadOnly(); currentErrorToCount = "Error_tapeLoad"; waitForDrive(); diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index facefe53460b38112447656d24d2104872e4ad73..fb775ef5853a3f5e5f1e265daebd8ca42b1be3ab 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -173,15 +173,6 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::openWriteSession() { new castor::tape::tapeFile::WriteSession(m_drive, m_volInfo, m_lastFseq, m_compress, m_useLbp) ); - cta::log::ScopedParamContainer params(m_logContext); - params.add("vo",m_archiveMount.getVo()); - params.add("mediaType",m_archiveMount.getMediaType()); - params.add("tapePool",m_archiveMount.getPoolName()); - params.add("logicalLibrary",m_drive.config.logicalLibrary); - params.add("mountType",mountTypeToString(m_volInfo.mountType)); - params.add("vendor",m_archiveMount.getVendor()); - params.add("capacityInBytes",m_archiveMount.getCapacityInBytes()); - m_logContext.log(cta::log::INFO, "Tape session started"); } catch (cta::exception::Exception & e) { ScopedParam sp0(m_logContext, Param("ErrorMessage", e.getMessageValue())); @@ -317,6 +308,15 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting, m_logContext); // Before anything, the tape should be mounted // This call does the logging of the mount + cta::log::ScopedParamContainer params(m_logContext); + params.add("vo",m_archiveMount.getVo()); + params.add("mediaType",m_archiveMount.getMediaType()); + params.add("tapePool",m_archiveMount.getPoolName()); + params.add("logicalLibrary",m_drive.config.logicalLibrary); + params.add("mountType",mountTypeToString(m_volInfo.mountType)); + params.add("vendor",m_archiveMount.getVendor()); + params.add("capacityInBytes",m_archiveMount.getCapacityInBytes()); + m_logContext.log(cta::log::INFO, "Tape session started"); mountTapeReadWrite(); currentErrorToCount = "Error_tapeLoad"; waitForDrive(); diff --git a/xroot_plugins/XrdCtaArchiveFileLs.hpp b/xroot_plugins/XrdCtaArchiveFileLs.hpp index 98c7205933828378d4b55f2aca5a808c9a5d2929..4de3e98df858429e5e009d8f60ab68e86f7ef960 100644 --- a/xroot_plugins/XrdCtaArchiveFileLs.hpp +++ b/xroot_plugins/XrdCtaArchiveFileLs.hpp @@ -130,7 +130,10 @@ public: dlen = streambuf->Size(); XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "GetBuff(): Returning buffer with ", dlen, " bytes of data."); } catch(cta::exception::Exception &ex) { - throw std::runtime_error(ex.getMessage().str()); + std::ostringstream errMsg; + errMsg << __FUNCTION__ << " failed: Caught CTA exception: " << ex.what(); + eInfo.Set(errMsg.str().c_str(), ECANCELED); + delete streambuf; } catch(std::exception &ex) { std::ostringstream errMsg; errMsg << __FUNCTION__ << " failed: " << ex.what(); diff --git a/xroot_plugins/XrdCtaListPendingQueue.hpp b/xroot_plugins/XrdCtaListPendingQueue.hpp index 5953ed60cdbbd2c71965b5dbfdf5982184476752..09fcc0778277cfa10daa71062597ec752a0b9476 100644 --- a/xroot_plugins/XrdCtaListPendingQueue.hpp +++ b/xroot_plugins/XrdCtaListPendingQueue.hpp @@ -116,7 +116,10 @@ public: dlen = streambuf->Size(); XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "GetBuff(): Returning buffer with ", dlen, " bytes of data."); } catch(exception::Exception &ex) { - throw std::runtime_error(ex.getMessage().str()); + std::ostringstream errMsg; + errMsg << __FUNCTION__ << " failed: Caught CTA exception: " << ex.what(); + eInfo.Set(errMsg.str().c_str(), ECANCELED); + delete streambuf; } catch(std::exception &ex) { std::ostringstream errMsg; errMsg << __FUNCTION__ << " failed: " << ex.what(); diff --git a/xroot_plugins/XrdCtaTapePoolLs.hpp b/xroot_plugins/XrdCtaTapePoolLs.hpp index 3d2301217c87622878ce0144d7e410d57a5fda82..76356c47c6f2fb9327f80dba56838dd4cdc46e3f 100644 --- a/xroot_plugins/XrdCtaTapePoolLs.hpp +++ b/xroot_plugins/XrdCtaTapePoolLs.hpp @@ -110,7 +110,10 @@ public: dlen = streambuf->Size(); XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "GetBuff(): Returning buffer with ", dlen, " bytes of data."); } catch(cta::exception::Exception &ex) { - throw std::runtime_error(ex.getMessage().str()); + std::ostringstream errMsg; + errMsg << __FUNCTION__ << " failed: Caught CTA exception: " << ex.what(); + eInfo.Set(errMsg.str().c_str(), ECANCELED); + delete streambuf; } catch(std::exception &ex) { std::ostringstream errMsg; errMsg << __FUNCTION__ << " failed: " << ex.what(); diff --git a/xroot_plugins/cta-frontend.logrotate b/xroot_plugins/cta-frontend.logrotate index 01660befd1c28dcb41ed5b71fae1c483eb22aba8..b90c60eb5a9f7d537d6425cb65bdfe83cf9cd32a 100644 --- a/xroot_plugins/cta-frontend.logrotate +++ b/xroot_plugins/cta-frontend.logrotate @@ -14,7 +14,7 @@ missingok rotate 500 copytruncate - create 755 cta cta + create 755 cta tape compress delaycompress }