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

Throw a separate exception if ESGetToken is uninitialized #30506

Merged
merged 3 commits into from
Sep 8, 2020

Conversation

makortel
Copy link
Contributor

@makortel makortel commented Jul 2, 2020

PR description:

In #30482 it was noticed that a get() with uninitialized ESGetToken throws an exception complaining on incorrect transition ID. This is confusing and inconsistent with EDGetToken and EDPutToken. This PR changes EventSetupRecord::getHandleImpl() to first check if a token is initialized, and then check if the transition is correct.

In addition, scram b code-format lead to partial reformatting of EventSetupRecord.h (perhaps this file was missed in code formatting campaign after a clang version update or something), I included those changes in a separate commit.

PR validation:

Framework unit tests run.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30506/16700

  • This PR adds an extra 28KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

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

It involves the following packages:

FWCore/Framework

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

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

makortel commented Jul 2, 2020

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

The tests are being triggered in jenkins.

assert(iToken.isInitialized());
if UNLIKELY (not iToken.isInitialized()) {
std::rethrow_exception(makeInvalidTokenException(this->key(), DataKey::makeTypeTag<T>()));
}
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 I ended up re-using makeInvalidTokenException() because the exception message of that was about the same I had in mind. But that makes me ask ...

UNLIKELY(not iToken.hasValidIndex()) { return invalidTokenHandle<H>(iToken); }
if UNLIKELY (not iToken.hasValidIndex()) {
return invalidTokenHandle<H>(iToken);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

... if this check (which is the only caller of makeInvalidTokenException()) would still be useful? Can ESGetToken be constructed with a valid transition ID but invalid index?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the data product is not available that would happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then the exception message of that appears to be confusing. invalidTokenHandle()

H<T> invalidTokenHandle(ESGetToken<T, R> const& iToken) const {
auto const key = this->key();
return H<T>{
makeESHandleExceptionFactory([key] { return makeInvalidTokenException(key, DataKey::makeTypeTag<T>()); })};
}

just leads to makeInvalidTokenException() that creates
std::exception_ptr EventSetupRecord::makeInvalidTokenException(EventSetupRecordKey const& iRecordKey,
TypeTag const& iDataKey) {
cms::Exception ex("InvalidESGetToken");
ex << "Attempted to get data using an invalid token of type ESGetToken<" << iDataKey.name() << ","
<< iRecordKey.name()
<< ">.\n"
"Please call consumes to properly initialize the token.";
return std::make_exception_ptr(ex);
}

that suggests to call consumes, which should be unrelated to (in)availability of the data product.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We concluded that a valid transition ID and invalid index should not happen, so I'll replace this exception message.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

+1
Tested at: 771ba07
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4d7028/7615/summary.html
CMSSW: CMSSW_11_2_X_2020-07-02-1100
SCRAM_ARCH: slc7_amd64_gcc820

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4d7028/7615/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 37
  • DQMHistoTests: Total histograms compared: 2784120
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2784069
  • DQMHistoTests: Total skipped: 50
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 36 files compared)
  • Checked 154 log files, 17 edm output root files, 37 DQM output files

@makortel makortel changed the title Throw a separate exception if ESgetToken is uninitialized Throw a separate exception if ESGetToken is uninitialized Jul 3, 2020
@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30506/18163

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

Pull request #30506 was updated. @makortel, @smuzaffar, @cmsbuild, @Dr15Jones can you please check and sign again.

@makortel
Copy link
Contributor Author

makortel commented Sep 4, 2020

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

The tests are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

+1
Tested at: c62a716
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4d7028/9129/summary.html
CMSSW: CMSSW_11_2_X_2020-09-04-1100
SCRAM_ARCH: slc7_amd64_gcc820

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2020

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4d7028/9129/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 35
  • DQMHistoTests: Total histograms compared: 2609667
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2609644
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 34 files compared)
  • Checked 149 log files, 22 edm output root files, 35 DQM output files

@makortel
Copy link
Contributor Author

makortel commented Sep 8, 2020

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 8, 2020

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. @silviodonato, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2)

@silviodonato
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 6ee16df into cms-sw:master Sep 8, 2020
@makortel makortel deleted the esgettokenThrowUninitialized branch September 8, 2020 14:17
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.

4 participants