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

Show customer_grid indexer as green when realtime #34557

Conversation

fredden
Copy link
Member

@fredden fredden commented Nov 6, 2021

Description

Magento recommends that all indexers be set in schedule mode ("Update by Schedule") except for customer_grid which should be in realtime mode ("Update on Save"). This is documented here in the devdocs and the Site-Wide Analysis Tool reports this also.

Screen-shot of Site-Wide Analysis Tool

Screenshot_2021-11-06_21-37-48


Currently Magento renders all indexers as 'green' when they are in schedule mode, including customer_grid. This is misleading as the customer_grid is not in the recommended state when set as schedule and shows in 'red' when in realtime mode which is its recommended state.

This pull request makes the colours match the recommended state for each indexer.

Related Pull Requests

None

Fixed Issues

None

Manual testing scenarios

  1. Set all indexers as realtime with: php bin/magento indexer:set-mode realtime
  2. Observe colours for each indexer in admin (System -> Tools -> Index Management)
  3. Set all indexers as schedule with: php bin/magento indexer:set-mode schedule
  4. Observe colours for each indexer in admin (System -> Tools -> Index Management)
  5. Set the customer_grid indexer as realtime with: php bin/magento indexer:set-mode realtime customer_grid
  6. Observe colours for each indexer in admin (System -> Tools -> Index Management)
Screen-shot of indexers all set 'Update on Save'

Screenshot_2021-11-06_21-48-58

Screen-shot of indexers all set 'Update by Schedule'

Screenshot_2021-11-06_21-50-32

Screen-shot of indexers set to their recommended modes

Screenshot_2021-11-06_21-45-49

Questions or comments

I have made the function which determines the preferred mode public to allow for extensibility with plugins.

Should the Design Config Grid indexer also be in this category of 'prefer realtime mode'?

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] Show customer_grid indexer as green when realtime #34648: Show customer_grid indexer as green when realtime

@m2-assistant
Copy link

m2-assistant bot commented Nov 6, 2021

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.

🎥 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-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.

@andrewbess
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @andrewbess. Thank you for your request. I'm working on Magento instance for you.

bjornmeat added a commit to bjornmeat/devdocs that referenced this pull request Nov 7, 2021
We have experienced confusion related to setting of customer_grid indexer. Adding clarification above screenshot.
Also screenshot needs to be updated if magento/magento2#34557 is merged.
@hostep
Copy link
Contributor

hostep commented Nov 8, 2021

Can somebody please verify if the claim is actually correct? We have always had that indexer set to 'update by schedule' and I haven't heard any complaints about our clients that this customer grid is not being updated correctly...

@fredden
Copy link
Member Author

fredden commented Nov 8, 2021

Can somebody please verify if the claim is actually correct?

Yes, please; I'd like confirmation too. I've not witnessed any real-world issues with this (in current versions of Magento) nor the Design Config Grid indexer, but both seem to use the 'dummy' materialised-view, so will never get anything in their (non-existent) changelog tables and therefore won't run an 'incremental' indexer update. I wonder why the Design Config Grid isn't marked as recommended in realtime mode too. This feels inconsistent.

Code samples showing 'dummy' mview

<indexer id="customer_grid" view_id="customer_dummy" class="Magento\Framework\Indexer\Action\Entity" primary="customer">

<view id="customer_dummy" class="Magento\Framework\Indexer\Action\Dummy" group="indexer"/>

<indexer id="design_config_grid" view_id="design_config_dummy" class="Magento\Theme\Model\Indexer\Design\Config" primary="design_config">

<view id="design_config_dummy" class="Magento\Framework\Indexer\Action\Dummy" group="indexer"/>

class Dummy implements ActionInterface, MviewActionInterface
{
/**
* Execute full indexation
*
* @return void
*/
public function executeFull()
{
}
/**
* Execute partial indexation by ID list
*
* @param int[] $ids
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function executeList(array $ids)
{
}
/**
* Execute partial indexation by ID
*
* @param int $id
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function executeRow($id)
{
}
/**
* Execute materialization on ids entities
*
* @param int[] $ids
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute($ids)
{
}
}

@fredden
Copy link
Member Author

fredden commented Nov 8, 2021

It looks like the customer grid indexer gets incremental updates inline within the same process that's doing the 'save' action.

public function afterSave()
{
if ($this->getIndexer()->getState()->getStatus() == StateInterface::STATUS_VALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}
/**
* Init indexing process after customer delete
*
* @return \Magento\Framework\Model\AbstractModel
*/
public function afterDeleteCommit()
{
$this->reindex();
return parent::afterDeleteCommit();
}
/**
* Init indexing process after customer save
*
* @return void
*/
public function reindex()
{
$this->getIndexer()->reindexRow($this->getId());
}

public function afterSave()
{
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() == StateInterface::STATUS_VALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}
/**
* Init indexing process after customer delete
*
* @return \Magento\Framework\Model\AbstractModel
*/
public function afterDeleteCommit()
{
$this->reindex();
return parent::afterDeleteCommit();
}
/**
* Init indexing process after customer save
*
* @return void
*/
public function reindex()
{
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexRow($this->getCustomerId());
}

public function aroundDelete(Website $subject, callable $proceed): Website
{
$customerIds = $this->getCustomerIdsByWebsiteId((int) $subject->getId());
$result = $proceed();
if ($customerIds) {
$this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID)
->reindexList($customerIds);
}
return $result;
}

And the Design Config Grid indexer does a full reindex every time something gets saved.

public function save(DesignConfigInterface $designConfig)
{
if (!($designConfig->getExtensionAttributes() &&
$designConfig->getExtensionAttributes()->getDesignConfigData())
) {
throw new LocalizedException(
__("The config can't be saved because it's empty. Complete the config and try again.")
);
}
$this->getValidator()->validate($designConfig);
$this->configStorage->save($designConfig);
$this->reinitableConfig->reinit();
$this->reindexGrid();
return $designConfig;
}
/**
* @inheritDoc
*/
public function delete(DesignConfigInterface $designConfig)
{
if (!($designConfig->getExtensionAttributes() &&
$designConfig->getExtensionAttributes()->getDesignConfigData())
) {
throw new LocalizedException(
__("The config can't be saved because it's empty. Complete the config and try again.")
);
}
$this->configStorage->delete($designConfig);
$this->reinitableConfig->reinit();
$this->reindexGrid();
return $designConfig;
}
/**
* Synchronize design config grid
*
* @return void
*/
protected function reindexGrid()
{
$this->indexerRegistry->get(DesignConfig::DESIGN_CONFIG_GRID_INDEXER_ID)->reindexAll();
}

So the indexer mode ('realtime' versus 'schedule') shouldn't make any difference to the freshness of the data showing in the grid. Should we therefore mark the mode as neutral whatever it is, rather than preferring one state over the other?

@fredden fredden force-pushed the indexer-status-customer-grid branch from 509fb51 to 08a22ef Compare November 8, 2021 23:26
@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-Alfa
Copy link
Contributor

@magento create issue

@m2-community-project m2-community-project bot added the Priority: P3 May be fixed according to the position in the backlog. label Nov 16, 2021
@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.

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

@sinhaparul sinhaparul added the Project: Community Picked PRs upvoted by the community label Jul 26, 2023
@engcom-Echo
Copy link
Contributor

@magento run Unit 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 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.

@engcom-Echo
Copy link
Contributor

@fredden can you please have a look a static test failure seems to be causing because of the PR changes

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

@engcom-Echo
Copy link
Contributor

@magento run WebAPI Tests, Unit Tests,Functional Tests EE,Functional Tests CE,Functional Tests B2B

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

@engcom-Echo
Copy link
Contributor

@magento run Unit Tests,WebAPI 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 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.

@engcom-Echo
Copy link
Contributor

@magento run Unit Tests,WebAPI 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 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.

@engcom-Echo
Copy link
Contributor

engcom-Echo commented Aug 2, 2023

Failing Test does not seems to be related to PR and are known failure.
Hence moving it to Merge In Progress

@engcom-Echo
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 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.

@engcom-Echo
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 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.

@engcom-Echo
Copy link
Contributor

@magento run WebAPI Tests,Unit Tests,Static Tests, Functional Tests B2B

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

@engcom-Echo
Copy link
Contributor

Functional Tests B2B are different on last two run on same commit. Other failure are not related to PR.
Functional Tests B2B
Run1
34557-b2b

Run2
Screenshot 2023-08-18 at 12 26 46 PM

@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 634d286 into magento:2.4-develop Aug 31, 2023
@fredden fredden deleted the indexer-status-customer-grid branch August 31, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Indexer Partner: Fisheye partners-contribution Pull Request is created by Magento Partner Priority: P3 May be fixed according to the position in the backlog. Progress: accept Project: Community Picked PRs upvoted by the community Release Line: 2.4
Projects
Status: Recently Merged
Development

Successfully merging this pull request may close these issues.

[Issue] Show customer_grid indexer as green when realtime