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

Set default indexer mode to 'schedule' #36347

Closed

Conversation

fredden
Copy link
Member

@fredden fredden commented Oct 21, 2022

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

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • 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. resolves [Issue] Set default indexer mode to 'schedule' #36419: Set default indexer mode to 'schedule'

@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2022

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

❗ 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

ℹ️ 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.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-github-services m2-github-services added Partner: Fisheye partners-contribution Pull Request is created by Magento Partner labels Oct 21, 2022
@magento-automated-testing
Copy link

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.

@ishakhsuvarov
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

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-Lima
Copy link
Contributor

@magento create issue

@engcom-Lima
Copy link
Contributor

As per PO confirmation prioritizing this PR as P1.

@engcom-Lima engcom-Lima added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Nov 4, 2022
@magento-automated-testing
Copy link

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.

1 similar comment
@magento-automated-testing
Copy link

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.

@hostep
Copy link
Contributor

hostep commented Nov 19, 2022

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?)

@fredden
Copy link
Member Author

fredden commented Nov 19, 2022

@hostep that sounds like a good feature to add. I see that as separate from (but related to) this pull request and #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).

@sinhaparul sinhaparul added the Project: Community Picked PRs upvoted by the community label Mar 4, 2023
@ihor-sviziev
Copy link
Contributor

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?

@fredden
Copy link
Member Author

fredden commented Mar 9, 2023

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

@chernenm
Copy link

chernenm commented Dec 4, 2023

Hello @fredden, @ihor-sviziev, @hostep,

We have reviewed the PR internally one more time and agreed that since it is introducing additional risks for upgrade process, we should only go forward with the changes impacting only new installations for the time being.
So, the only change we would deliver would be:

  • When doing a fresh installation of Magento / Adobe Commerce 2.4.7 or any version above, all the indexers will be set in "Update by Schedule" mode by default and appear in status "Ready" after installation is complete.

And for the time being we will not be changing our current behavior during upgrade process. So, changes proposed in items 3 and 6 in the list above will not be delivered for the time being.

@ihor-sviziev
Copy link
Contributor

Hi @chernenm,
Please clarify which risks you're talking about. I don't see any risks.

@chernenm
Copy link

chernenm commented Dec 6, 2023

Hi @ihor-sviziev,

The main concern why we do not want to interfere upgrade flow is that by changing all the indexers into "Upgrade by Schedule" mode during the upgrade might potentially break the upgrade flow. If for example some extensions require reindex of their indexers during upgrade and we are resetting indexers state to "Update on Schedule" then before making an upgrade, all the customers need to make sure that crons are properly configured and and up and running, which is currently not a required step for patch release upgrade. Also, if crons are configured to be run every 1 minute, It additional 1 minute of delay, which might not also be expected in the extensions and customizations code, which might also cause additional issues during upgrade flow.
And since, we are trying to keep patch release upgrade process as smooth as possible for our customers, these changes which interfere upgrade flow, should not be delivered in scope of a patch version, so we would recommend to postpone this contribution at least till a minor release.

@fredden
Copy link
Member Author

fredden commented Dec 6, 2023

@chernenm it seems like you have misunderstood the changes in this pull request. You're talking about changing indexer mode during upgrade flow, which is not something that is happening here. Perhaps we can schedule a call about this if you need more information?

Copy link

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.

@m2-community-project m2-community-project bot added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Feb 28, 2024
@engcom-Charlie
Copy link
Contributor

As mentioned above comment threads, the required feature has been taken care in internal JIRA. Also as per the detailed information given by @chernenm here, closing this PR now.

@fredden
Copy link
Member Author

fredden commented Jul 2, 2024

@engcom-Charlie please re-open this pull request. You have misundersood the state of this task.

@engcom-Charlie
Copy link
Contributor

As mentioned here, moving this PR to On hold.

@fredden
Copy link
Member Author

fredden commented Jul 16, 2024

@engcom-Charlie what needs to happen so that we can get this merged in? You've marked this as "on hold" but I don't understand what the problem is here.

@hostep
Copy link
Contributor

hostep commented Aug 22, 2024

Look what just got merged in 2.4-develop today: AC-11421:In existing Magento installation when install third party indexer module set indexers in update by schedule by default:Change default Index mode schedule

It's a completely different implementation as the one proposed in this PR, but probably results in the same outcome. What do you think @fredden?

@engcom-Bravo
Copy link
Contributor

Hi @fredden,

Thanks for your Contribution!!

As per the requirement of https://jira.corp.adobe.com/browse/AC-6975 we delivered ‘Indexer default mode was schedule after Magento installation only’ and was not working when we install third-party Indexer(Custom Indexer) as default mode was still on save with third-party Indexer(Custom Indexer)
With new changes which are delivered in scope of https://jira.corp.adobe.com/browse/AC-11421 , if we install Magento or install third party Indexer(Custom Indexer), default mode will be schedule by default. It should resolve the issue raised in #36347 as well.

Related commits: https://github.com/search?q=repo%3Amagento%2Fmagento2+Arrows_Delivery_07022024&type=commits

Based on the Jira ticket, the target version is 2.4.8-beta1.

Thanks

@fredden fredden deleted the indexer-default-mode-schedule branch September 7, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Fisheye Partner: Youwe partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Project: Community Picked PRs upvoted by the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Set default indexer mode to 'schedule'