Skip to content

Allow ignored columns for mview to be specified at the subscription level #29692

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

Conversation

aligent-lturner
Copy link
Contributor

@aligent-lturner aligent-lturner commented Aug 20, 2020

Description (*)

Current configuration options for indexer subscriptions are limited - only allowing a table to be specified, rather than specific columns that we may be interested in.
Likewise \Magento\Framework\Mview\View\Subscription has the argument $ignoredUpdateColumns, which by default only includes updated_at. This argument is used to ignore columns for update triggers globally.

This change adds another argument to \Magento\Framework\Mview\View\Subscription to allow for columns to be ignored for a specific view/table combination (i.e. at the subscription level).

Example use-case:
You may wish to subscribe to the salesrule table for a custom indexer (e.g. view id of "my_custom_view"), but with current functionality, this results in a reindex occurring any time an order is placed which had the rule applied, due to the times_used column being updated.

With the following di.xml entries, we can specifically ignore the times_used column for our indexer view:

<type name="Magento\Framework\Mview\View\Subscription">
    <arguments>
        <argument name="ignoredUpdateColumnsBySubscription" xsi:type="array">
            <item name="my_custom_view" xsi:type="array">
                <item name="salesrule" xsi:type="array">
                    <item name="times_used" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </arguments>
</type>

Manual testing scenarios (*)

  1. Add di.xml configuration for an existing view - e.g. cataloginventory_stock:
    app/code/Magento/CatalogInventory/etc/di.xml
<type name="Magento\Framework\Mview\View\Subscription">
    <arguments>
        <argument name="ignoredUpdateColumnsBySubscription" xsi:type="array">
            <item name="cataloginventory_stock" xsi:type="array">
                <item name="cataloginventory_stock_item" xsi:type="array">
                    <item name="low_stock_date" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </arguments>
</type>
  1. Set all indexers to update on save (this will remove existing triggers)
  2. Set all indexers to update by schedule (this will create triggers again)
  3. Observe that updating cataloginventory_stock_item.low_stock_date does not create a record in cataloginventory_stock_cl, but does create records in catalogsearch_fulltext_cl and catalog_product_price_cl

Questions or comments

Not sure if there's any tests that can be updated/added for this change. Please feel free to suggest them (or even add them!)

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)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Allow ignored columns for mview to be specified at the subscription level #30243: Allow ignored columns for mview to be specified at the subscription level

@m2-assistant
Copy link

m2-assistant bot commented Aug 20, 2020

Hi @aligent-lturner. Thank you for your contribution
Here is 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

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, 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, please 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

@kandy kandy added Area: Perf/Frontend All tickets related with improving frontend performance. and removed Area: Perf/Frontend All tickets related with improving frontend performance. labels Aug 20, 2020
@BarnyShergold BarnyShergold self-assigned this Aug 21, 2020
@BarnyShergold
Copy link

@magento run all tests

Copy link

@BarnyShergold BarnyShergold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct formatting to fix test & fix functional tests

@aligent-lturner
Copy link
Contributor Author

@magento run all tests

@aligent-lturner
Copy link
Contributor Author

@magento run all tests

BarnyShergold
BarnyShergold previously approved these changes Aug 24, 2020
@magento-engcom-team
Copy link
Contributor

Hi @BarnyShergold, thank you for the review.
ENGCOM-8063 has been created to process this Pull Request
✳️ @BarnyShergold, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@BarnyShergold BarnyShergold added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Aug 24, 2020
@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Sep 30, 2020
@sidolov
Copy link
Contributor

sidolov commented Sep 30, 2020

@magento create issue

@gabrieldagama gabrieldagama added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests labels Nov 3, 2020
@magento-engcom-team
Copy link
Contributor

Hi @gabrieldagama, thank you for the review.
ENGCOM-8063 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

✔️ QA passed
Result is same as in comment

@engcom-Delta
Copy link
Contributor

Note: Automation tests are passed

@magento-engcom-team
Copy link
Contributor

Hi @BarnyShergold, thank you for the review.
ENGCOM-8063 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

engcom-Delta commented Nov 18, 2020

✔️ QA passed
Result:
✔️ Updating cataloginventory_stock_item.low_stock_date does not create a record in cataloginventory_stock_cl but does create records in catalogsearch_fulltext_cl and catalog_product_price_cl
Peek 2020-11-18 12-23

@engcom-Delta
Copy link
Contributor

Note: Automation tests are passed

@m2-assistant
Copy link

m2-assistant bot commented Nov 27, 2020

Hi @aligent-lturner, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@skovalenk
Copy link
Contributor

Guys, can you please be aligned to best practices. There is specific configuration for Mview, it is called mview.xml. Why you did this in DI.xml. For what purpose?

@aligent-lturner
Copy link
Contributor Author

Guys, can you please be aligned to best practices. There is specific configuration for Mview, it is called mview.xml. Why you did this in DI.xml. For what purpose?

Because there is existing configuration for ignoring columns in di.xml for the class in question. It makes sense to keep it together there. I agree that ideally, the configuration would be in mview.xml, but this would also require updating the associated xsd and would then also separate the configuration for globally ignored columns and those ignored for a specific view/table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Mview Partner: Aligent Consulting 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. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Allow ignored columns for mview to be specified at the subscription level
10 participants