Skip to content

Commit

Permalink
Fix bug in PoolSource when skipping events with a missing file
Browse files Browse the repository at this point in the history
If the configuration has N input files and skipEvents causes us to skip N-1 files and the last file can not be opened, the job would crash.
  • Loading branch information
Dr15Jones committed Feb 24, 2020
1 parent 1c6c569 commit 1d8f0bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
15 changes: 8 additions & 7 deletions IOPool/Input/src/RootPrimaryFileSequence.cc
Expand Up @@ -151,13 +151,14 @@ namespace edm {

initFile(input_.skipBadFiles());

if (rootFile()) {
// make sure the new product registry is compatible with the main one
std::string mergeInfo =
input_.productRegistryUpdate().merge(*rootFile()->productRegistry(), fileName(), branchesMustMatch_);
if (!mergeInfo.empty()) {
throw Exception(errors::MismatchedInputFiles, "RootPrimaryFileSequence::nextFile()") << mergeInfo;
}
if (not rootFile()) {
return false;
}
// make sure the new product registry is compatible with the main one
std::string mergeInfo =
input_.productRegistryUpdate().merge(*rootFile()->productRegistry(), fileName(), branchesMustMatch_);
if (!mergeInfo.empty()) {
throw Exception(errors::MismatchedInputFiles, "RootPrimaryFileSequence::nextFile()") << mergeInfo;
}
return true;
}
Expand Down
27 changes: 27 additions & 0 deletions IOPool/Input/test/PoolInputTest_skip_with_failure_cfg.py
@@ -0,0 +1,27 @@
# The following comments couldn't be translated into the new config version:

# Configuration file for PoolInputTest

import FWCore.ParameterSet.Config as cms

process = cms.Process("TESTRECO")
process.load("FWCore.Framework.test.cmsExceptionsFatal_cff")

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(-1)
)
process.OtherThing = cms.EDProducer("OtherThingProducer")

process.Analysis = cms.EDAnalyzer("OtherThingAnalyzer")

process.source = cms.Source("PoolSource",
skipBadFiles = cms.untracked.bool(True),
skipEvents = cms.untracked.uint32(15), #skips all events in first file
setRunNumber = cms.untracked.uint32(621),
fileNames = cms.untracked.vstring('file:PoolInputTest.root',
'file:this_file_doesnt_exist.root')
)

process.p = cms.Path(process.OtherThing*process.Analysis)


1 change: 1 addition & 0 deletions IOPool/Input/test/TestPoolInput.sh
Expand Up @@ -22,6 +22,7 @@ cp PoolInputTest.root PoolInputOther.root
cmsRun --parameter-set ${LOCAL_TEST_DIR}/PoolInputTest_cfg.py || die 'Failure using PoolInputTest_cfg.py' $?
cmsRun ${LOCAL_TEST_DIR}/PoolInputTest_noDelay_cfg.py >& ${LOCAL_TMP_DIR}/PoolInputTest_noDelay_cfg.txt || die 'Failure using PoolInputTest_noDelay_cfg.py' $?
grep 'event delayed read from source' ${LOCAL_TMP_DIR}/PoolInputTest_noDelay_cfg.txt && die 'Failure in PoolInputTest_noDelay_cfg.py, found delay reads from source' 1
cmsRun --parameter-set ${LOCAL_TEST_DIR}/PoolInputTest_skip_with_failure_cfg.py || die 'Failure using PoolInputTest_skip_with_failure_cfg.py' $?

cmsRun ${LOCAL_TEST_DIR}/PrePool2FileInputTest_cfg.py || die 'Failure using PrePool2FileInputTest_cfg.py' $?
cmsRun ${LOCAL_TEST_DIR}/Pool2FileInputTest_cfg.py || die 'Failure using Pool2FileInputTest_cfg.py' $?
Expand Down

0 comments on commit 1d8f0bf

Please sign in to comment.