Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce EventSetup products can be obtained only with ESGetToken #35588

Merged
merged 4 commits into from Dec 13, 2021

Conversation

makortel
Copy link
Contributor

@makortel makortel commented Oct 8, 2021

PR description:

This PR is intended only for 12_3_X, but is opened already now to find test code outside of framework that would fail with it so we can start migrating those.

This PR changes the deprecated EventSetupRecord::get() function to throw an exception, causing all code accessing EventSetup products without ESGetToken.

Resolves cms-sw/framework-team#96

PR validation:

Framework unit tests except three (that I will discuss below) succeed.

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 8, 2021

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35588/25840

  • This PR adds an extra 88KB to repository

Code check has found code style and quality issues which could be resolved by applying following patch(s)

Remove all tests of the deprecated API for which tests for the new API
exist, and migrate the rest.
@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 8, 2021

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35588/25841

  • This PR adds an extra 88KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 8, 2021

A new Pull Request was created by @makortel (Matti Kortelainen) for master.

It involves the following packages:

  • FWCore/Framework (core)

@cmsbuild, @smuzaffar, @Dr15Jones, @makortel can you please review it and eventually sign? Thanks.
@wddgit this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

makortel commented Oct 8, 2021

test parameters:

  • full_cmssw = true

@makortel
Copy link
Contributor Author

makortel commented Oct 8, 2021

@cmsbuild, please test

Copy link
Contributor Author

@makortel makortel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pointed out the checks in eventsetuprecord_t test that fail currently. I've been focusing on proxyResetTest(), and transientTest() looks somewhat similar. I have not looked to getExepTest() much yet.

CPPUNIT_ASSERT(&myDummy == &(*hDummy));
CPPUNIT_ASSERT(!workingProxy->invalidateCalled());
CPPUNIT_ASSERT(!workingProxy->invalidateTransientCalled());

dummyProvider->resetProxies();
CPPUNIT_ASSERT(workingProxy->invalidateCalled());
CPPUNIT_ASSERT(workingProxy->invalidateTransientCalled());
dummyRecord.get(hDummy);
hDummy = dummyRecord.getHandle(token);
CPPUNIT_ASSERT(&myDummy2 == &(*hDummy));
CPPUNIT_ASSERT(!workingProxy->invalidateCalled());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check fails.


dummyRecord.get(hDummy);
hDummy = dummyRecord.getHandleImpl<edm::ESHandle>(token);
CPPUNIT_ASSERT(&myDummy2 == &(*hDummy));
nonConstDummyRecordImpl.resetIfTransientInProxies();
CPPUNIT_ASSERT(workingProxy->invalidateCalled() == false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check fails.

dummyRecord.setImpl(&dummyRecordImpl, 0, nullptr, &eventSetupImpl_, &pc, false);
dummyRecord.get(dummyPtr);
dummyRecord.setImpl(&dummyRecordImpl, 0, getTokenIndices.data(), &eventSetupImpl_, &pc);
ESHandle<Dummy> dummyPtr = dummyRecord.getHandle(token);
//CPPUNIT_ASSERT_THROW(dummyRecord.get(dummyPtr), ExceptionType);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test expects edm::eventsetup::MakeDataException to be thrown, but it isn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That exception originates from

if UNLIKELY (nullptr == cache_) {
throwMakeException(iRecord, iKey);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FailingDummyProxy returns a nullptr from its functions that generate the ES product. That should definitely trigger the exception. What happens of you try to dereference the handle?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a big difference is calling EventSetupRecord::get(edm::ESHandle<....>....) will trigger running the DataProxy, while EventSetupRecord::getHandle will not. So I think you need to explicitly trigger the DataProxy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr15Jones Is this getExepTest() actually useful given

void testEventsetupRecord::getHandleTest() {
FailingDummyProxy dummyProxy;
const DataKey dummyDataKey(DataKey::makeTypeTag<FailingDummyProxy::value_type>(), "");
ESHandle<Dummy> dummyPtr;
{
DummyDataConsumer consumer{edm::ESInputTag("", "")};
SetupRecord sr{consumer, dummyRecordKey_, eventSetupImpl_, &activityRegistry, {}};
DummyRecord dummyRecord = sr.makeRecord();
CPPUNIT_ASSERT(not dummyRecord.getHandle(consumer.m_token));
dummyPtr = dummyRecord.getHandle(consumer.m_token);
CPPUNIT_ASSERT(not dummyPtr.isValid());
CPPUNIT_ASSERT(not dummyPtr);
CPPUNIT_ASSERT(dummyPtr.failedToGet());
CPPUNIT_ASSERT_THROW(*dummyPtr, NoDataExceptionType);
CPPUNIT_ASSERT_THROW(makeESValid(dummyPtr), cms::Exception);
}

@makortel
Copy link
Contributor Author

makortel commented Oct 9, 2021

@smuzaffar Does the bot run tests for draft PRs?

@smuzaffar
Copy link
Contributor

@smuzaffar Does the bot run tests for draft PRs?

Yes it does

@smuzaffar
Copy link
Contributor

Please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 9, 2021

-1

Failed Tests: UnitTests RelVals AddOn
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-cea191/19511/summary.html
COMMIT: 5538699
CMSSW: CMSSW_12_1_X_2021-10-08-2300/slc7_amd64_gcc900
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/35588/19511/install.sh to create a dev area with all the needed externals and cmssw changes.

Unit Tests

I found errors in the following unit tests:

---> test test_MuonGeometryDBConverter had ERRORS
---> test TestDQMOnlineClient-hcalreco_dqm_sourceclient had ERRORS
---> test TestDQMOnlineClient-l1tstage2emulator_dqm_sourceclient had ERRORS
---> test TestDQMOnlineClient-mutracking_dqm_sourceclient had ERRORS
and more ...

RelVals

----- Begin Fatal Exception 09-Oct-2021 12:19:00 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 274199 stream: 0
   [1] Calling method for module L1TCaloLayer1/'simCaloStage2Layer1Digis'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HcalTrigTowerGeometry label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
----- Begin Fatal Exception 09-Oct-2021 12:19:00 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 301998 stream: 0
   [1] Calling method for module L1TCaloLayer1/'simCaloStage2Layer1Digis'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HcalTrigTowerGeometry label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
----- Begin Fatal Exception 09-Oct-2021 12:19:00 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 319450 stream: 0
   [1] Calling method for module L1TCaloLayer1/'simCaloStage2Layer1Digis'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HcalTrigTowerGeometry label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
Expand to see more relval errors ...

AddOn Tests

----- Begin Fatal Exception 09-Oct-2021 12:21:30 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 1 stream: 0
   [1] Calling method for module HiggsValidation/'hplusValidation'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HepPDT::ParticleDataTable label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
----- Begin Fatal Exception 09-Oct-2021 12:21:29 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 1 stream: 2
   [1] Calling method for module HiggsValidation/'hplusValidation'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HepPDT::ParticleDataTable label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
----- Begin Fatal Exception 09-Oct-2021 12:21:30 CEST-----------------------
An exception of category 'MustUseESGetToken' occurred while
   [0] Processing  stream begin Run run: 1 stream: 0
   [1] Calling method for module HiggsValidation/'hplusValidation'
Exception Message:
Called EventSetupRecord::get without using a ESGetToken.
 While requesting data type:HepPDT::ParticleDataTable label:''
See https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHowToGetDataFromES
for instructions how to migrate the calling code
----- End Fatal Exception -------------------------------------------------
Expand to see more addon errors ...

@makortel
Copy link
Contributor Author

makortel commented Oct 9, 2021

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 7, 2021

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2)

@perrotta
Copy link
Contributor

please test
(to refresh them before merging)

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-cea191/21208/summary.html
COMMIT: 958abb5
CMSSW: CMSSW_12_3_X_2021-12-12-0000/slc7_amd64_gcc900
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/35588/21208/install.sh to create a dev area with all the needed externals and cmssw changes.

CMS deprecated warnings: 39 CMS deprecated warnings found, see summary page for details.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 42
  • DQMHistoTests: Total histograms compared: 3250704
  • DQMHistoTests: Total failures: 11
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 3250670
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 41 files compared)
  • DQMHistoSizes: changed ( 312.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 177 log files, 37 edm output root files, 42 DQM output files
  • TriggerResults: no differences found

@qliphy
Copy link
Contributor

qliphy commented Dec 13, 2021

enable threading
just to make sure further there will be no issue in IB tests with multithreading

@qliphy
Copy link
Contributor

qliphy commented Dec 13, 2021

please test

@cmsbuild
Copy link
Contributor

-1

Failed Tests: UnitTests
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-cea191/21209/summary.html
COMMIT: 958abb5
CMSSW: CMSSW_12_3_X_2021-12-12-0000/slc7_amd64_gcc900
Additional Tests: THREADING
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/35588/21209/install.sh to create a dev area with all the needed externals and cmssw changes.

CMS deprecated warnings: 39 CMS deprecated warnings found, see summary page for details.

Unit Tests

I found errors in the following unit tests:

---> test testCondToolsSiStripBuildersReaders had ERRORS

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 2 differences found in the comparisons
  • DQMHistoTests: Total files compared: 42
  • DQMHistoTests: Total histograms compared: 3250704
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3250676
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 41 files compared)
  • Checked 177 log files, 37 edm output root files, 42 DQM output files
  • TriggerResults: no differences found

@qliphy
Copy link
Contributor

qliphy commented Dec 13, 2021

the unit test failure is not related to this PR:
#36319

@perrotta
Copy link
Contributor

+1

  • Unit test error in the last tests is uncorrelated
  • It is probably time to finally enforce EventSetup products to be obtained only with ESGetToken, now that we are at the beginning of the 12_3_X cycle: lets do it now, and see in the coming days if there are any remaining modules to fix, in case any crashes appear in relvals or unit tests

@perrotta
Copy link
Contributor

merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[12_3_X] Throw exception for EDModules calling deprecated EventSetupRecord::get()
7 participants