magento2
magento2 copied to clipboard
Set default indexer mode to 'schedule'
Description
It is recommended that indexers be in the schedule
("Update by Schedule") mode, and not realtime
("Update on Save") mode. However, when Magento is installed for the first time, all indexers are by default in the "wrong" mode. This pull request changes the default for new indexers to be in the expected / recommended mode.
This change will not impact any existing indexers and therefore existing websites should not notice any impact from this change. If a module with an indexer is installed on an existing website, it will be created with the new default mode: schedule
.
Manual testing scenarios
- Install Magento anew
- Navigate in the admin to System -> Tools -> Index Management
- Notice the colour of the "Mode" column. Before this change, these were all red, indicating an error/problem; after this change these are all green, indicating that all is well.
- Install a module which adds indexers (such as
algolia/algoliasearch-magento-2
) - Navigate in the admin to System -> Tools -> Index Management
- Notice the colour of the "Mode" column. Before this change, new indexers were all red, indicating an error/problem; after this change these are all green, indicating that all is well.
Contribution checklist
- [x] Pull request has a meaningful description of its purpose
- [x] All commits are accompanied by meaningful commit messages
- [x] All new or changed code is covered with unit/integration tests (if applicable)
- [x] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Resolved issues:
- [x] resolves magento/magento2#36419: Set default indexer mode to 'schedule'
Hi @fredden. Thank you for your contribution Here are some useful tips how you can test your changes using Magento test environment. Add the comment under your pull request to deploy test or vanilla Magento instance:
-
@magento give me test instance
- deploy test instance based on PR changes -
@magento give me 2.4-develop instance
- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
-
@magento run all tests
- run or re-run all required tests against the PR changes -
@magento run <test-build(s)>
- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)>
is a comma-separated list of build names. Allowed build names are:
-
Database Compare
-
Functional Tests CE
-
Functional Tests EE
, -
Functional Tests B2B
-
Integration Tests
-
Magento Health Index
-
Sample Data Tests CE
-
Sample Data Tests EE
-
Sample Data Tests B2B
-
Static Tests
-
Unit Tests
-
WebAPI Tests
-
Semantic Version Checker
You can find more information about the builds here
:information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Magento Contributor Guide documentation.
:warning: According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento create issue
As per PO confirmation prioritizing this PR as P1.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
Additionally - not sure if this is in scope of this PR - it would nice if an indexer definition could specify what its default mode should be the first time it gets setup. I seem to remember a particular 3rd party module from Amasty that comes with a couple of indexers where they strongly recommend to keep them set at 'Update on Save' (I can't find that recommendation anymore at the moment..., so not sure how needed this feature would be anymore, but maybe other modules have similar requirements?)
@hostep that sounds like a good feature to add. I see that as separate from (but related to) this pull request and https://github.com/magento/magento2/pull/34557 (where the preferred mode is shown in the admin - I specifically made Magento\Indexer\Block\Backend\Grid\Column\Renderer\Scheduled::isPreferRealtime()
public there so it could be adjusted via plugin, but reading from an developer-defined preferred mode makes sense too).
Hi @fredden, AFAIK when you're changing the indexer mode from real-time to scheduled, Magento also creates triggers on needed tables. Will the need triggers be created automatically with your changes?
@ihor-sviziev that's a great question. I've tested this just now. I started with a fresh environment, checked out this branch, and ran php bin/magento setup:install
with all the relevant flags.
Running php bin/magento indexer:status
shows all indexers are in 'schedule' mode. Inspecting the database I can see that these indexers do have triggers set up as expected.
For example, mysqldump
creates the following SQL statements among others:
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`magento2`@`%`*/ /*!50003 TRIGGER trg_catalog_category_entity_int_after_insert AFTER INSERT ON catalog_category_entity_int FOR EACH ROW
BEGIN
INSERT IGNORE INTO `catalog_category_product_cl` (`entity_id`) VALUES (NEW.`entity_id`);
END */;;
DELIMITER ;
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@engcom-Hotel please can you help me with these test failures?
Database Compare
From what I can tell, the complaint here is that an 'updated' timestamp has been changed. This seems like a false alert to me.
Functional Tests B2B
Unfortunately there's no build reports were generated. That may be caused by either infrastructure issues or fatal errors during the build run. Please address this issue to Community Engineering Team members.
Functional Tests EE
Unfortunately there's no build reports were generated. That may be caused by either infrastructure issues or fatal errors during the build run. Please address this issue to Community Engineering Team members.
Functional Tests CE
There are many test failures, but I can't find any useful error messages. What's the problem with this test-suite?
Integration Tests
The errors related to B2B & EE seem like failures to install the application properly. I'm not sure how to diagnose this.
I've tried to fix the errors for CE by running 'bin/magento indexer:reindex', but the build-in mechanism for this does not work within the test-suite. I'll try to investigate this further, but some help here would be appreciated.
Sample Data Tests B2B
Unfortunately there's no build reports were generated. That may be caused by either infrastructure issues or fatal errors during the build run. Please address this issue to Community Engineering Team members.
Sample Data Tests EE
Unfortunately there's no build reports were generated. That may be caused by either infrastructure issues or fatal errors during the build run. Please address this issue to Community Engineering Team members.
Unit Tests
The failures here seem related to daylight saving time. I expect these errors will go away in ~6 days as that then the time "7 days ago" will be the same. This is a failure which is unrelated to this pull request.
WebAPI Tests
This suffers from the same problems as "Integration Tests" above.
I've figured out how to run the integration test suites locally (see https://github.com/magento/magento2/issues/32252). I cannot reproduce the problems that the Adobe systems are reporting. @engcom-Hotel please can you pick this up internally and report back with your findings.
Sure @fredden, Let me ask someone from the team to pick this PR.
Thanks
@fredden Thank you fixing this issue.
It will be taken care into one of the Internal JIRA ticket. Once Internal PR will get merged, we will notify.
Thank you!
CC @ihor-sviziev @hostep
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
I've investigated the failing Unit Test and opened https://github.com/magento/magento2/pull/37287 to resolve the error therein.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
As mentioned in above comment internal team is working on this PR in internal JIRA. Team is working on some implementation level changes. Once the JIRA will get merge will notify it here.
Thank you!
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
Hello,
Internal Team Work in progress to fix the Automation tests. So far, All 3 types of MFTFs, Integration, WebAPI Tests are fixed.
Thanks.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
@fredden We have raised the Mainline PRs for this issue. It is estimated to be merged soon. Once Internal PRs gets merge, we will keep you posted on this.
Thank you!
CC @ihor-sviziev @hostep