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

Fix thread safety issues in SwitchProducer ProductResolvers #28686

Merged
merged 8 commits into from Dec 31, 2019

Conversation

makortel
Copy link
Contributor

PR description:

This PR fixes three thread safety issues in SwitchProducer ProductResolvers that I realized while addressing #28680

  • SwitchBaseProductResolver::prefetchRequested_ is now re-set to false in resetProductData_()
    • Current behavior (without re-setting) could lead to starvation if there are many consumers (in Tasks) for the SwitchProducer products. This indeed happens with enhanced tests (multiple consumers, multiple threads)
  • Call ProductData::unsafe_setWrapper() in the prefetching phase as suggested by @Dr15Jones in Thread safety issue in SwitchBaseProductResolver::resolveProductImpl #28680
    • The ordering of the tasks ensures that exactly one task is accessing the ProductData at the time of the call, after which the tasks for the product consumers are spawned.
  • SwitchBaseProductResolver::waitingTasks_ is reset in resetProductData_()
    • Current behavior (without reset) leads to product consumer tasks being spawned too early from 2nd event onwards

In addition this PR

  • Moves putProduct_() from SwitchBaseProductResolver to SwitchProducerProductResolver
    • The putProduct_() should never be called from SwitchAliasProductResolver (and now throws an exception)
  • Moves the call to updateProvenance() to a proper place in SwitchProducerProductResolver
    • The earlier placement looked suspicious (why update if got an exception), and the problem in the provenance tracking was confirmed by enhancing the tests to check the provenance information also for the test configuration where the SwitchProcucer is in a Path

Fixes #28680.

PR validation:

Code compiles, unit tests run.

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28686/13257

  • This PR adds an extra 40KB to repository

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

…oductResolver

putProduct_() should never be called fro SwitchAliasProductResolver,
which means that the infrastructure to support putProduct_() is not
common for the two. Moving the function to
SwitchProducerProductResolver makes the intentions more clear.

Also remove a useless return from updateProvenance().
Found by checking provenance from SwitchProducer-in-Path as well
@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28686/13258

  • This PR adds an extra 40KB to repository

@cmsbuild
Copy link
Contributor

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

It involves the following packages:

FWCore/Framework
FWCore/Integration

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

cms-bot commands are listed here

1 similar comment
@cmsbuild
Copy link
Contributor

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

It involves the following packages:

FWCore/Framework
FWCore/Integration

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

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 27, 2019

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-run-pr-tests/4107/console Started: 2019/12/27 21:24

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28686/13263

  • This PR adds an extra 52KB to repository

@cmsbuild
Copy link
Contributor

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

@makortel
Copy link
Contributor Author

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 30, 2019

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-run-pr-tests/4110/console Started: 2019/12/30 18:47

@cmsbuild
Copy link
Contributor

+1
Tested at: d521f7f
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-16228b/4110/summary.html
CMSSW: CMSSW_11_1_X_2019-12-30-1100
SCRAM_ARCH: slc7_amd64_gcc820

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-16228b/4110/summary.html

Comparison Summary:

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

@Dr15Jones
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

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

@fabiocos
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 8f299bc into cms-sw:master Dec 31, 2019
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.

Thread safety issue in SwitchBaseProductResolver::resolveProductImpl
4 participants