-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Handle exceptions thrown in child processes forked by ProcessManager #30626
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
Handle exceptions thrown in child processes forked by ProcessManager #30626
Conversation
Hi @pawel-siejba. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
Can be easily back ported all the way to 2.3.0 Without any changes up to 2.3.2, 2.3.0 - 2.3.1 have some phpcs comments removed, but the class stays intact. |
@pawel-siejba |
86bede4
to
bdf911a
Compare
@magento run Static Tests |
@ihor-sviziev I'll try to write some Unit Tests but I'm not sure if PHPUnit will handle that well as we will be essentially testing process forking. |
@magento run all tests |
@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B |
@ihor-sviziev It doesn't look like writing Unit tests in this case will be feasible. Additional extensions installed may be required, on top of that it looks to be impossible to Unit test this implementation of Process manager in a way that would prove useful to this PR - without mocking/replacing the pcntl extension function calls. Moreover forking inside a Unit test doesn't seem like the best idea to me. |
Hi @ihor-sviziev, thank you for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pawel-siejba with new changes we have same output as before but it is recorded into exception.log file. Could you clarify if this is expected behavior with your fix?
Manual testing scenario:
- Create additional website with products
- Run MAGE_INDEXER_THREADS_COUNT=4 php bin/magento indexer:reindex catalogsearch_fulltext
- Kill Elasticsearch process to simulate an exception thrown (e.g.,
kill pid
command)
Output with fix in console:
Output with fix in log file:
exception.log
@engcom-Delta Yes, this is the expected behaviour. BTW don't know if you noticed but you unveiled another bug with the ProcessManager that I will create a separate issue for as it's not related to this change and also reproducible without this change. Basically if MAGE_INDEXER_THREADS_COUNT > Number of dimensions(in your case 3 stores) the main process always exits successfully. |
@pawel-siejba thanks for clarification |
Hi @ihor-sviziev, thank you for the review. |
✔️ QA passed After:
Note: Issue with the main process always exits successfully is reproducible on 2.4-develop without fix: |
Note: Automation tests are passed |
Hi @pawel-siejba, thank you for your contribution! |
Description (*)
The following bug can have fatal consequences if somebody employed any form of exception handling around indexers in their installation, as it could lead to very hard to discover bugs, that appear only on environments with several threads available, and MAGE_INDEXER_THREADS_COUNT env variable set.
As of now in Vanilla Magento 3 indexers(catalogsearch_fulltext, catalog_category_product, catalog_product_price) use the process manager for splitting index dimensions into separate processes.
If one of the subprocesses fails, it's not exited immediately, instead the exception continues through parent's execution flow
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)