From dddfd09d2d4802a2bab8aab3ca4058a04514e444 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Mar 2023 12:13:16 -0500 Subject: [PATCH] Add temporary failure element to Framework Job Report Until the job report finishes, we add a FrameworkError element to denote that if the job suddenly ends the error will be present. When job completes successfully or with another error, that temporary element is not written. The new error was added to edm::errors. --- FWCore/MessageLogger/interface/JobReport.h | 1 + FWCore/MessageLogger/src/JobReport.cc | 28 +++++++++++++++++-- .../FrameworkJobReport-timing_t.xml | 1 + .../unit_test_outputs/FrameworkJobReport.xml | 1 + .../test/unit_test_outputs/job_report.xml | 1 + .../test/unit_test_outputs/u10_job_report.xml | 1 + .../unit_test_outputs/u14_job_report.mxml | 1 + .../unit_test_outputs/u16_job_report.mmxml | 1 + .../test/unit_test_outputs/u1_job_report.mxml | 1 + .../unit_test_outputs/u1d_job_report.mxml | 1 + .../test/unit_test_outputs/u27FJR.xml | 1 + .../test/unit_test_outputs/u7_job_report.mxml | 1 + FWCore/Utilities/interface/EDMException.h | 2 ++ FWCore/Utilities/src/EDMException.cc | 1 + IOPool/Common/test/proper_RLfjr_output | 1 + IOPool/Common/test/proper_Rfjr_output | 1 + IOPool/Common/test/proper_fjr_output | 1 + IOPool/Common/test/proper_fjrx_output | 1 + IOPool/Common/test/proper_fjrx_second_output | 1 + 19 files changed, 45 insertions(+), 2 deletions(-) diff --git a/FWCore/MessageLogger/interface/JobReport.h b/FWCore/MessageLogger/interface/JobReport.h index 331eefe4ec86c..006f41013c43c 100644 --- a/FWCore/MessageLogger/interface/JobReport.h +++ b/FWCore/MessageLogger/interface/JobReport.h @@ -430,6 +430,7 @@ namespace edm { void temporarilyCloseXML(); edm::propagate_const> impl_; std::mutex write_mutex; + bool errorLogged_ = false; }; std::ostream& operator<<(std::ostream& os, JobReport::InputFile const& f); diff --git a/FWCore/MessageLogger/src/JobReport.cc b/FWCore/MessageLogger/src/JobReport.cc index 380e5c7e67fbe..3d4f68cbf335b 100644 --- a/FWCore/MessageLogger/src/JobReport.cc +++ b/FWCore/MessageLogger/src/JobReport.cc @@ -302,10 +302,29 @@ namespace edm { } } + static constexpr std::string_view kJobReportEndElement = "\n"; + static constexpr int kMinSizeOfComment = 8; + JobReport::~JobReport() { impl_->flushFiles(); if (impl_->ost_) { - *(impl_->ost_) << "\n" << std::flush; + //are we actually at the end of the file? + auto pos = impl_->ost_->tellp(); + impl_->ost_->seekp(0, std::ios_base::end); + auto endpos = impl_->ost_->tellp(); + impl_->ost_->seekp(pos); + if ((endpos - pos) > static_cast(kJobReportEndElement.size())) { + //need to add some padding so use a comment element + // comment is used since white spaces are converted to a special node + // while comments are usually ignored by xml parsers + auto padding = (endpos - pos) - (kJobReportEndElement.size() + kMinSizeOfComment); + *(impl_->ost_) << "\n"; + } + *(impl_->ost_) << kJobReportEndElement << std::flush; } } @@ -313,7 +332,11 @@ namespace edm { if (impl_->ost_) { //remember where we were auto pos = impl_->ost_->tellp(); - *(impl_->ost_) << "\n" << std::flush; + if (not errorLogged_) { + *(impl_->ost_) << "\n"; + } + *(impl_->ost_) << kJobReportEndElement << std::flush; + //overwrite above during next write. impl_->ost_->seekp(pos); } @@ -507,6 +530,7 @@ namespace edm { if (impl_->ost_) { { std::lock_guard lock(write_mutex); + errorLogged_ = true; std::ostream& msg = *(impl_->ost_); msg << "\n"; msg << "\n"; diff --git a/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport-timing_t.xml b/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport-timing_t.xml index 63c26f56da911..7f8c7ac34d19e 100644 --- a/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport-timing_t.xml +++ b/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport-timing_t.xml @@ -8,4 +8,5 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport.xml b/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport.xml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport.xml +++ b/FWCore/MessageService/test/unit_test_outputs/FrameworkJobReport.xml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/job_report.xml b/FWCore/MessageService/test/unit_test_outputs/job_report.xml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/job_report.xml +++ b/FWCore/MessageService/test/unit_test_outputs/job_report.xml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u10_job_report.xml b/FWCore/MessageService/test/unit_test_outputs/u10_job_report.xml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u10_job_report.xml +++ b/FWCore/MessageService/test/unit_test_outputs/u10_job_report.xml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u14_job_report.mxml b/FWCore/MessageService/test/unit_test_outputs/u14_job_report.mxml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u14_job_report.mxml +++ b/FWCore/MessageService/test/unit_test_outputs/u14_job_report.mxml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u16_job_report.mmxml b/FWCore/MessageService/test/unit_test_outputs/u16_job_report.mmxml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u16_job_report.mmxml +++ b/FWCore/MessageService/test/unit_test_outputs/u16_job_report.mmxml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u1_job_report.mxml b/FWCore/MessageService/test/unit_test_outputs/u1_job_report.mxml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u1_job_report.mxml +++ b/FWCore/MessageService/test/unit_test_outputs/u1_job_report.mxml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u1d_job_report.mxml b/FWCore/MessageService/test/unit_test_outputs/u1d_job_report.mxml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u1d_job_report.mxml +++ b/FWCore/MessageService/test/unit_test_outputs/u1d_job_report.mxml @@ -1,2 +1,3 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u27FJR.xml b/FWCore/MessageService/test/unit_test_outputs/u27FJR.xml index 3c7d37cce5de2..fd28f2179aa57 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u27FJR.xml +++ b/FWCore/MessageService/test/unit_test_outputs/u27FJR.xml @@ -10,4 +10,5 @@ + diff --git a/FWCore/MessageService/test/unit_test_outputs/u7_job_report.mxml b/FWCore/MessageService/test/unit_test_outputs/u7_job_report.mxml index 96b56471bad2c..590a5bf944660 100644 --- a/FWCore/MessageService/test/unit_test_outputs/u7_job_report.mxml +++ b/FWCore/MessageService/test/unit_test_outputs/u7_job_report.mxml @@ -1,2 +1,3 @@ + diff --git a/FWCore/Utilities/interface/EDMException.h b/FWCore/Utilities/interface/EDMException.h index 1c87bc99e085d..ac02488f47df7 100644 --- a/FWCore/Utilities/interface/EDMException.h +++ b/FWCore/Utilities/interface/EDMException.h @@ -72,6 +72,8 @@ namespace edm { EventGenerationFailure = 8501, + UnexpectedJobTermination = 8901, + CaughtSignal = 9000 }; diff --git a/FWCore/Utilities/src/EDMException.cc b/FWCore/Utilities/src/EDMException.cc index 077b849d8c8b4..3d5c9ba6c478b 100644 --- a/FWCore/Utilities/src/EDMException.cc +++ b/FWCore/Utilities/src/EDMException.cc @@ -46,6 +46,7 @@ namespace edm { FILLENTRY(UnavailableAccelerator), FILLENTRY(ExternalFailure), FILLENTRY(EventGenerationFailure), + FILLENTRY(UnexpectedJobTermination), FILLENTRY(CaughtSignal)}; static const std::string kUnknownCode("unknownCode"); } // namespace errors diff --git a/IOPool/Common/test/proper_RLfjr_output b/IOPool/Common/test/proper_RLfjr_output index f74829c7b37dd..449b71704064b 100644 --- a/IOPool/Common/test/proper_RLfjr_output +++ b/IOPool/Common/test/proper_RLfjr_output @@ -81,4 +81,5 @@ + diff --git a/IOPool/Common/test/proper_Rfjr_output b/IOPool/Common/test/proper_Rfjr_output index 49af6c12a58eb..443754eee17bd 100644 --- a/IOPool/Common/test/proper_Rfjr_output +++ b/IOPool/Common/test/proper_Rfjr_output @@ -77,4 +77,5 @@ + diff --git a/IOPool/Common/test/proper_fjr_output b/IOPool/Common/test/proper_fjr_output index d75397307a6d6..8f679f474e2ec 100644 --- a/IOPool/Common/test/proper_fjr_output +++ b/IOPool/Common/test/proper_fjr_output @@ -83,4 +83,5 @@ + diff --git a/IOPool/Common/test/proper_fjrx_output b/IOPool/Common/test/proper_fjrx_output index 54423565eeb5d..6335e52e5be0d 100644 --- a/IOPool/Common/test/proper_fjrx_output +++ b/IOPool/Common/test/proper_fjrx_output @@ -92,4 +92,5 @@ + diff --git a/IOPool/Common/test/proper_fjrx_second_output b/IOPool/Common/test/proper_fjrx_second_output index 27d561881be66..ecf67cd6796f9 100644 --- a/IOPool/Common/test/proper_fjrx_second_output +++ b/IOPool/Common/test/proper_fjrx_second_output @@ -80,4 +80,5 @@ +