magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Set default indexer mode to 'schedule'

Open fredden opened this issue 2 years ago • 61 comments

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

  1. Install Magento anew
  2. Navigate in the admin to System -> Tools -> Index Management
  3. 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.
  4. Install a module which adds indexers (such as algolia/algoliasearch-magento-2)
  5. Navigate in the admin to System -> Tools -> Index Management
  6. 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:

  1. [x] resolves magento/magento2#36419: Set default indexer mode to 'schedule'

fredden avatar Oct 21 '22 10:10 fredden

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:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. 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

m2-assistant[bot] avatar Oct 21 '22 10:10 m2-assistant[bot]

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

ishakhsuvarov avatar Nov 03 '22 18:11 ishakhsuvarov

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

engcom-Lima avatar Nov 04 '22 06:11 engcom-Lima

As per PO confirmation prioritizing this PR as P1.

engcom-Lima avatar Nov 04 '22 07:11 engcom-Lima

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 avatar Nov 19 '22 11:11 hostep

@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).

fredden avatar Nov 19 '22 20:11 fredden

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 avatar Mar 09 '23 17:03 ihor-sviziev

@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 ;

fredden avatar Mar 09 '23 18:03 fredden

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.

fredden avatar Mar 14 '23 11:03 fredden

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.

fredden avatar Mar 14 '23 12:03 fredden

Sure @fredden, Let me ask someone from the team to pick this PR.

Thanks

engcom-Hotel avatar Mar 15 '23 05:03 engcom-Hotel

@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

rimple-saini avatar Mar 17 '23 09:03 rimple-saini

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.

fredden avatar Mar 23 '23 15:03 fredden

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!

engcom-Charlie avatar Apr 25 '23 09:04 engcom-Charlie

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.

engcom-Bravo avatar Jun 01 '23 09:06 engcom-Bravo

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

rimple-saini avatar Aug 10 '23 17:08 rimple-saini

As per this, moving this PR to Merge In Progress.

Thank you!

engcom-Charlie avatar Aug 11 '23 05:08 engcom-Charlie