Skip to content

Commit 036086c

Browse files
committed
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.
1 parent 95393a0 commit 036086c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎Framework/AODMerger/src/aodValidator.cxx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ int validate(const char* url, bool deep, int maxReports)
5454
printf("BAD %s/%s: %s\n", df, tree, what.c_str());
5555
}
5656
};
57+
// A read which failed because the connection to the storage was lost leaves
58+
// the file closed: the rest of the file cannot be checked, which is not damage.
59+
auto lost = [&]() {
60+
if (file->IsOpen()) {
61+
return false;
62+
}
63+
printf("ERROR: lost the connection to %s after %d DFs\n", url, dfs);
64+
return true;
65+
};
5766
if (file->TestBit(TFile::kRecovered)) {
5867
report("", "", "the file was not closed: ROOT recovered its keys, the DF folders may be empty");
5968
}
@@ -65,6 +74,9 @@ int validate(const char* url, bool deep, int maxReports)
6574
++dfs;
6675
std::unique_ptr<TDirectory> dir((TDirectory*)key->ReadObj());
6776
if (!dir) {
77+
if (lost()) {
78+
return -1;
79+
}
6880
report(key->GetName(), "", "cannot read the folder");
6981
continue;
7082
}
@@ -75,6 +87,9 @@ int validate(const char* url, bool deep, int maxReports)
7587
}
7688
std::unique_ptr<TTree> tree((TTree*)treeKey->ReadObj());
7789
if (!tree) {
90+
if (lost()) {
91+
return -1;
92+
}
7893
report(key->GetName(), treeKey->GetName(), "cannot read the tree");
7994
continue;
8095
}
@@ -97,6 +112,9 @@ int validate(const char* url, bool deep, int maxReports)
97112
if (deep) {
98113
char buffer[256];
99114
if (file->ReadBuffer(buffer, seek, std::min<Long64_t>(sizeof(buffer), size - seek))) {
115+
if (lost()) {
116+
return -1;
117+
}
100118
report(key->GetName(), tree->GetName(), Form("branch %s basket %d: cannot read its key at %lld", br->GetName(), b, seek));
101119
continue;
102120
}

0 commit comments

Comments
 (0)