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

Optimize QuoteIdToMaskedQuoteId model and fix infinite loop #33324

Merged
merged 1 commit into from
Nov 21, 2021

Conversation

ihor-sviziev
Copy link
Contributor

@ihor-sviziev ihor-sviziev commented Jun 23, 2021

Description (*)

This PR stops using cart repository and using tiny code that checks only if such a quote exists.

I compared the same request w/o and with changes from PR and got ~40% time response improvement (tested with Blackfire):
image

Also, it fixes the infinite loop described in #33675, as the logic was rewritten to small SQL queries.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Adding masked quote id to QuoteRepository::getList causing infinite loop #33675
  2. Fixes Using QuoteIdToMaskedQuoteId shouldn't increase response time #33676
  3. Fixes \Klaviyo\Reclaim\Plugin\Api\CartSearchRepository::afterGetList Infinite Loop klaviyo/magento2-klaviyo#133

Manual testing scenarios (*)

  1. See issue details

Questions or comments

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)

@m2-assistant
Copy link

m2-assistant bot commented Jun 23, 2021

Hi @ihor-sviziev. 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

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

@ihor-sviziev ihor-sviziev added Triage: Performance Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Jun 23, 2021
@ihor-sviziev
Copy link
Contributor Author

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

@ihor-sviziev
Copy link
Contributor Author

FYI We have test coverage for this functionality in https://github.com/magento/magento2/blob/f4db7d458884bcfc3d21b35b41f4fbe8e91bcb0f/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteIdToMaskedQuoteIdTest.php

I think it's good enough to mark this PR with a "covered" label.

@ihor-sviziev
Copy link
Contributor Author

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

@ihor-sviziev
Copy link
Contributor Author

@magento run Magento Health Index

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

@Den4ik
Copy link
Contributor

Den4ik commented Jun 23, 2021

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

@ihor-sviziev ihor-sviziev force-pushed the patch-15 branch 2 times, most recently from 4c66569 to cb1ef06 Compare June 24, 2021 06:50
@ihor-sviziev
Copy link
Contributor Author

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

@ihor-sviziev
Copy link
Contributor Author

@magento run Integration 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 re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@eduard13 eduard13 left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@magento-engcom-team
Copy link
Contributor

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

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Preconditions:

  1. Have Magento instance installed with sample data.
  2. Install Klaviyo extension (tested on version 3.0.5)

Manual testing scenario:

  1. Admin > Create Cart Price Rule with coupon (let's give some 10% discount)

  2. Frontend > Add a product to the shopping cart and apply the above created discount coupon.

  3. Use the POST Request http://local.magento2.com/rest/default/V1/integration/admin/token to get the token

  4. Use the GET carts request to validate its response http://local.magento2.com/index.php/rest/default/V1/carts/search?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][condition_type]=gt&searchCriteria[sortOrders][0][field]=updated_at&searchCriteria[sortOrders][0][direction]=DESC&searchCriteria[currentPage]=1&searchCriteria[pageSize]=50&searchCriteria[filter_groups][0][filters][0][value]=2021-09-09

Before: ✖️ Request was responding with server error response as shown in below screenshot (It is slightly different that what shown in the above issue description)

image

After: ✔️ Responding with proper cart details

image

There is no additional testing is requited since it is a API request issue on a particular case. Also there is Auto Test - covered and hence no additional regression is required to it.

@ihor-sviziev
Copy link
Contributor Author

@magento convert to patch for 2.4.3-p1

@ihor-sviziev
Copy link
Contributor Author

@magento convert to patch for 2.4.3

@m2-github-services
Copy link
Collaborator

@ihor-sviziev changes has been successfully converted for 2.4.3 version and pushed to the converted-magento-magento2-2.4.3 branch.

You may submit a pull request using the link: 2.4.3-release...magento:converted-magento-magento2-2.4.3

@m2-github-services
Copy link
Collaborator

@ihor-sviziev changes has been successfully converted for 2.4.3 version and pushed to the converted-magento-magento2-2.4.3 branch.

You may submit a pull request using the link: 2.4.3-release...magento:converted-magento-magento2-2.4.3

This pull request was closed.
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 Award: category of expertise Component: Quote Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Triage: Performance
Projects
None yet
8 participants