{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/13378","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/13378/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/13378/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/13378/events","html_url":"https://github.com/magento/magento2/issues/13378","id":291827343,"number":13378,"title":"Catalog price rule save is too slow","user":{"login":"udovicic","id":1079201,"avatar_url":"https://avatars0.githubusercontent.com/u/1079201?v=4","gravatar_id":"","url":"https://api.github.com/users/udovicic","html_url":"https://github.com/udovicic","followers_url":"https://api.github.com/users/udovicic/followers","following_url":"https://api.github.com/users/udovicic/following{/other_user}","gists_url":"https://api.github.com/users/udovicic/gists{/gist_id}","starred_url":"https://api.github.com/users/udovicic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/udovicic/subscriptions","organizations_url":"https://api.github.com/users/udovicic/orgs","repos_url":"https://api.github.com/users/udovicic/repos","events_url":"https://api.github.com/users/udovicic/events{/privacy}","received_events_url":"https://api.github.com/users/udovicic/received_events","type":"User","site_admin":false},"labels":[{"id":688811200,"url":"https://api.github.com/repos/magento/magento2/labels/G1%20Passed","name":"G1 Passed","color":"0e8a16","default":false},{"id":686476746,"url":"https://api.github.com/repos/magento/magento2/labels/G3%20Passed","name":"G3 Passed","color":"0e8a16","default":false},{"id":686477069,"url":"https://api.github.com/repos/magento/magento2/labels/Reproduced%20on%202.1.x","name":"Reproduced on 2.1.x","color":"e99695","default":false},{"id":686477126,"url":"https://api.github.com/repos/magento/magento2/labels/Reproduced%20on%202.2.x","name":"Reproduced on 2.2.x","color":"e99695","default":false},{"id":686477167,"url":"https://api.github.com/repos/magento/magento2/labels/Reproduced%20on%202.3.x","name":"Reproduced on 2.3.x","color":"e99695","default":false},{"id":21716835,"url":"https://api.github.com/repos/magento/magento2/labels/acknowledged","name":"acknowledged","color":"02d7e1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-01-26T08:16:10Z","updated_at":"2018-02-09T15:15:03Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!--- Provide a general summary of the issue in the Title above -->\r\n<!--- Before adding new issues, please, check this article https://github.com/magento/magento2/wiki/Issue-reporting-guidelines-->\r\n\r\n### Preconditions\r\n<!--- Provide a more detailed information of environment you use -->\r\n<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. -->\r\n1. Have a large enough data set\r\n2. Set indexing mode to `Reindex on schedule`\r\n\r\n### Steps to reproduce\r\n<!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant  -->\r\n1. Go to admin and create new catalog price rule that has condition based on category\r\n2. Hit save\r\n\r\n### Expected result\r\n<!--- Tell us what should happen -->\r\n1. New catalog price rule should be saved within reasonable time\r\n\r\n### Actual result\r\n<!--- Tell us what happens instead -->\r\n1. Request times out\r\n\r\n<!--- (This may be platform independent comment) -->\r\n### Details\r\n\r\nThere are actually more than one thing wrong here:\r\n1) Function [after save](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogRule/Model/Rule.php#L520-L523) of `Magento\\CatalogRule\\Model\\Rule` walks through collection of products and triggers the reindex, regardless of indexing setting. It may do nothing, but the fact that it does go over the data set makes this action really slow. Plus, depending on third party integrations, it may trigger unwanted sync at this point. And I know that what third party extensions do is not under your control, just pointing out that something is triggered and that is not supposed to happen at this time.\r\n\r\n2) They way it fetches the affected products is wrong. Function [getMatchingProductIds](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogRule/Model/Rule.php#L289-L321) will not scope the collection by category. And if that is your only condition, you will get whole catalog, even though the rule will affect only two products in that category. With the large enough set, code will end up checking potentially hundreds of thousands of products instead of just one category.\r\n\r\nCombining these two, you get additional actions triggered where not necessary, on a data set that is too large in the first place hence the transaction timing out. I have observed this on just 140k products in the catalog."},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/364461593","html_url":"https://github.com/magento/magento2/issues/13378#issuecomment-364461593","issue_url":"https://api.github.com/repos/magento/magento2/issues/13378","id":364461593,"user":{"login":"magento-engcom-team","id":31669971,"avatar_url":"https://avatars1.githubusercontent.com/u/31669971?v=4","gravatar_id":"","url":"https://api.github.com/users/magento-engcom-team","html_url":"https://github.com/magento-engcom-team","followers_url":"https://api.github.com/users/magento-engcom-team/followers","following_url":"https://api.github.com/users/magento-engcom-team/following{/other_user}","gists_url":"https://api.github.com/users/magento-engcom-team/gists{/gist_id}","starred_url":"https://api.github.com/users/magento-engcom-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magento-engcom-team/subscriptions","organizations_url":"https://api.github.com/users/magento-engcom-team/orgs","repos_url":"https://api.github.com/users/magento-engcom-team/repos","events_url":"https://api.github.com/users/magento-engcom-team/events{/privacy}","received_events_url":"https://api.github.com/users/magento-engcom-team/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T15:15:02Z","updated_at":"2018-02-09T15:15:02Z","author_association":"CONTRIBUTOR","body":"@udovicic, thank you for your report.\nWe've acknowledged the issue and added to our backlog."}}
{"actor":{"display_login":"magento-engcom-team"}}