Commit b32ccd33 authored by Steven Murray's avatar Steven Murray
Browse files

[Catalogue] operations#179 Slow `cta-admin sq` even when there is very little activity

Added NB_EMPTY_TAPES, NB_DISABLED_TAPES, NB_FULL_TAPES and
NB_READ_ONLY_TAPES columns to getTapePools() query.
parent a669fd92
......@@ -9156,6 +9156,10 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
 
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(1, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
......@@ -9176,6 +9180,10 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
 
ASSERT_EQ(tapePoolName2, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(1, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
......@@ -9289,6 +9297,10 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
 
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -9348,6 +9360,10 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
 
ASSERT_EQ(tapePoolName2, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -9950,6 +9966,153 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, summary.totalBytes);
ASSERT_EQ(0, summary.totalFiles);
}
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
// I AM HERE
// tape1.vid
m_catalogue->setTapeDisabled(m_admin, tape1.vid, true);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(1, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeDisabled(m_admin, tape1.vid, false);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeFull(m_admin, tape1.vid, true);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(1, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeFull(m_admin, tape1.vid, false);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeReadOnly(m_admin, tape1.vid, true);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(1, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeReadOnly(m_admin, tape1.vid, false);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
}
 
TEST_P(cta_catalogue_CatalogueTest, DISABLED_concurrent_filesWrittenToTape_many_archive_files) {
......
......@@ -1991,6 +1991,10 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
"TAPE_POOL.SUPPLY AS SUPPLY,"
"COALESCE(COUNT(TAPE.VID), 0) AS NB_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.DATA_IN_BYTES = 0 THEN 1 ELSE 0 END), 0) AS NB_EMPTY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED <> 0 THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_FULL <> 0 THEN 1 ELSE 0 END), 0) AS NB_FULL_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_READ_ONLY <> 0 THEN 1 ELSE 0 END), 0) AS NB_READ_ONLY_TAPES,"
"COALESCE(SUM(MEDIA_TYPE.CAPACITY_IN_BYTES), 0) AS CAPACITY_IN_BYTES,"
"COALESCE(SUM(TAPE.DATA_IN_BYTES), 0) AS DATA_IN_BYTES,"
"COALESCE(SUM(TAPE.LAST_FSEQ), 0) AS NB_PHYSICAL_FILES,"
......@@ -2040,6 +2044,10 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
pool.encryption = rset.columnBool("IS_ENCRYPTED");
pool.supply = rset.columnOptionalString("SUPPLY");
pool.nbTapes = rset.columnUint64("NB_TAPES");
pool.nbEmptyTapes = rset.columnUint64("NB_EMPTY_TAPES");
pool.nbDisabledTapes = rset.columnUint64("NB_DISABLED_TAPES");
pool.nbFullTapes = rset.columnUint64("NB_FULL_TAPES");
pool.nbReadOnlyTapes = rset.columnUint64("NB_READ_ONLY_TAPES");
pool.capacityBytes = rset.columnUint64("CAPACITY_IN_BYTES");
pool.dataBytes = rset.columnUint64("DATA_IN_BYTES");
pool.nbPhysicalFiles = rset.columnUint64("NB_PHYSICAL_FILES");
......
......@@ -29,6 +29,10 @@ TapePool::TapePool():
nbPartialTapes(0),
encryption(false),
nbTapes(0),
nbEmptyTapes(0),
nbDisabledTapes(0),
nbFullTapes(0),
nbReadOnlyTapes(0),
capacityBytes(0),
dataBytes(0),
nbPhysicalFiles(0) {
......@@ -57,6 +61,10 @@ std::ostream &operator<<(std::ostream &os, const TapePool &obj) {
<< " nbPartialTapes=" << obj.nbPartialTapes
<< " encryption=" << obj.encryption
<< " nbTapes=" << obj.nbTapes
<< " nbEmptyTapes=" << obj.nbEmptyTapes
<< " nbDisabledTapes=" << obj.nbDisabledTapes
<< " nbFullTapes=" << obj.nbFullTapes
<< " nbReadOnlyTapes=" << obj.nbReadOnlyTapes
<< " capacityBytes=" << obj.capacityBytes
<< " dataBytes=" << obj.dataBytes
<< " creationLog=" << obj.creationLog
......
......@@ -80,6 +80,26 @@ struct TapePool {
*/
uint64_t nbTapes;
/**
* The total number of empty tapes in the pool.
*/
uint64_t nbEmptyTapes;
/**
* The total number of disabled tapes in the pool.
*/
uint64_t nbDisabledTapes;
/**
* The total number of full tapes in the pool.
*/
uint64_t nbFullTapes;
/**
* The total number of read-only tapes in the pool.
*/
uint64_t nbReadOnlyTapes;
/**
* The total capacity of all the tapes in the pool in bytes.
*/
......
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