From 120709897d858a3064e00d1f8b9a6081b0e874ec Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:33:10 +0100 Subject: [PATCH] AOD: report a lost storage connection as unreadable in o2-aod-validator When the connection to the storage drops in the middle of a file ("Invalid address", then "The remote file is not open"), TFile closes the file and every later read fails. The validator reported each remaining DF as "cannot read the folder" and counted it as a problem, so the part of the file it could not read counted as damage: LHC25a2b/7/527899/AOD/015 came out with 57 problems, of which 8 are real. This happened to 8 of 20 files retried from the job_error_files.list sample. Check whether the file is still open before reporting a failed read of a folder, a tree or (with --deep) a basket key. If it is not, print that the connection was lost after N DFs and report the file as unreadable (exit code 2), like a file which cannot be opened. --- Framework/AODMerger/src/aodValidator.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Framework/AODMerger/src/aodValidator.cxx b/Framework/AODMerger/src/aodValidator.cxx index ac713fad7d30f..161a912d90d4d 100644 --- a/Framework/AODMerger/src/aodValidator.cxx +++ b/Framework/AODMerger/src/aodValidator.cxx @@ -54,6 +54,15 @@ int validate(const char* url, bool deep, int maxReports) printf("BAD %s/%s: %s\n", df, tree, what.c_str()); } }; + // A read which failed because the connection to the storage was lost leaves + // the file closed: the rest of the file cannot be checked, which is not damage. + auto lost = [&]() { + if (file->IsOpen()) { + return false; + } + printf("ERROR: lost the connection to %s after %d DFs\n", url, dfs); + return true; + }; if (file->TestBit(TFile::kRecovered)) { report("", "", "the file was not closed: ROOT recovered its keys, the DF folders may be empty"); } @@ -65,6 +74,9 @@ int validate(const char* url, bool deep, int maxReports) ++dfs; std::unique_ptr dir((TDirectory*)key->ReadObj()); if (!dir) { + if (lost()) { + return -1; + } report(key->GetName(), "", "cannot read the folder"); continue; } @@ -75,6 +87,9 @@ int validate(const char* url, bool deep, int maxReports) } std::unique_ptr tree((TTree*)treeKey->ReadObj()); if (!tree) { + if (lost()) { + return -1; + } report(key->GetName(), treeKey->GetName(), "cannot read the tree"); continue; } @@ -97,6 +112,9 @@ int validate(const char* url, bool deep, int maxReports) if (deep) { char buffer[256]; if (file->ReadBuffer(buffer, seek, std::min(sizeof(buffer), size - seek))) { + if (lost()) { + return -1; + } report(key->GetName(), tree->GetName(), Form("branch %s basket %d: cannot read its key at %lld", br->GetName(), b, seek)); continue; }