diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 821404fdfbf47f1773456be94dc48ce81e3721fd..468882e3e43dc46fe10474c2b1f02d44fb218d99 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -12,6 +12,7 @@ - cta/CTA#251 - Increase free drive STALE threshold to 4 hours - cta/CTA#218 - Do not retry during repack requests ### Bug Fixes +- cta/CTA#181 - cta-statistics-update can fail for catalogues in postgres - cta/CTA#234 - Replace stoi with toUint64 in standalone cli tool - cta/CTA#238 - Compilation fails when using cta::common::Configuration::getConfEntInt(...) ### Continuous Integration diff --git a/statistics/DatabaseStatisticsService.cpp b/statistics/DatabaseStatisticsService.cpp index 662aed6b424b593391fb10ba8a6e56e8038d659c..39c10c239a3d632dbaecb19976e58973e3ff40cd 100644 --- a/statistics/DatabaseStatisticsService.cpp +++ b/statistics/DatabaseStatisticsService.cpp @@ -16,6 +16,7 @@ */ #include <string> +#include <vector> #include "DatabaseStatisticsService.hpp" @@ -92,10 +93,16 @@ void DatabaseStatisticsService::updateStatisticsPerTape() { try { auto selectStmt = m_conn.createStmt(selectVids); auto rset = selectStmt.executeQuery(); + // Make a list of all dirty vids. The memory required for the list is + // expected to be acceptable. + std::vector<std::string> dirtyVids; while (rset.next()) { + dirtyVids.push_back(rset.columnString("VID")); + } + for (const auto & vid : dirtyVids) { // For all DIRTY tapes, update its statistics auto updateStmt = m_conn.createStmt(updateSql); - updateStmt.bindString(":VID", rset.columnString("VID")); + updateStmt.bindString(":VID", vid); updateStmt.executeNonQuery(); m_nbUpdatedTapes += updateStmt.getNbAffectedRows(); }