magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

setup upgrade command will purge whole full page cache (varnish) #37336

Closed onlinebizsoft closed 1 year ago

onlinebizsoft commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Run command setup:upgrade
  2. Validate cached pages in varnish

Expected result

Cached pages should stay in varnish

Actual result

Whole varnish were purged

Additional information

/vendor/magento/framework/App/Cache/Manager.php : get all cache type to clean

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @onlinebizsoft. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

onlinebizsoft commented 1 year ago

Do you have any idea about this behavior? @hostep @ihor-sviziev

ihor-sviziev commented 1 year ago

@onlinebizsoft I think it's designed like that because expecting this command to be executed during deployment. And when you deploy a new build, you probably might deploy some new module, new magento version, new css or js. And after the deployment you expect to see the change you deployed. I do agree that not all changes require varnish cache invalidation, but developing mechanism that will decide if we need to flush cache or no - pretty hard. From my perspective, we should keep such behavior as expected

onlinebizsoft commented 1 year ago

@ihor-sviziev but purging varnish can be done at very last step because after upgrading DB we will have di compile and deploy static steps which can take few hours for a system with so many languages (even ran multiple processes for deploying static). And the strange thing is that Magento clear varnish at that time but after finishing whole the deployment processes, we still have to clear varnish again. So what is the point doing it twice?

ihor-sviziev commented 1 year ago

@onlinebizsoft for production environment it should be the last step. Here are the docs how it should be https://devdocs.magento.com/guides/v2.3/config-guide/deployment/pipeline/technical-details.html#config-deploy-workflow

hostep commented 1 year ago

@onlinebizsoft: Ihor is correct, setup:upgrade (preferably with the --keep-generated flag) should be one of the last steps of the deployment process, setup:di:compile and setup:static-content:deploy should happen before that. And it's expected to flush the entire cache.

... and deploy static steps which can take few hours for a system with so many languages (even ran multiple processes for deploying static).

Multiple hours? That must surely mean there is something wrong, because that's insane. The longest deploy we have with a project takes 11 minutes and deploys 14 languages using 3 parallel jobs. You might be running against this bug, which was solved by https://github.com/magento/magento2/search?q=ACP2E-1168&type=commits

onlinebizsoft commented 1 year ago

@hostep our project has more than 60 languages so it took quite some time. I will look at deployment steps again, look like we shouldnt run upgrade before static.

m2-assistant[bot] commented 1 year ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 1 year ago

Hi @onlinebizsoft , We are closing this issue as there has been no latest update on the same. Kindly reopen / create new issue if you are still facing issues. Thank you.

onlinebizsoft commented 1 year ago

@engcom-November what do you mean by "no latest update on the same" ? Please re-open, this issue is still valid

m2-assistant[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


engcom-Dash commented 1 year ago

Hi @onlinebizsoft ,

Verified the issue in 2.4-develop instance and the issue is not reproducible.

Steps to reproduce: 1.Install magento instance 2.Run Setup Upgrade command 3.Validate cached pages in varnish as per Devedocs

Kindly refer the below screenshots:

Screenshot 2023-06-14 at 5 10 40 PM Screenshot 2023-06-14 at 5 11 05 PM

After upgrading cached pages stay in varnish only.

Let us know if we are missing anything!

hostep commented 1 year ago

@engcom-Dash: there's no good reason to put time in this issue.

@onlinebizsoft : I'm afraid Magento is designed like this to flush all caches each time bin/magento setup:upgrade runs, I don't think it's a good idea to attempt to change that, as it would probably break thousands of different workflows people are now used to use.

If it doesn't work in your workflow, then try to change your own workflow to make it work. Like Ihor said, you should run it almost at the very end of the deploy.

In my opinion this ticket should be closed again.

onlinebizsoft commented 1 year ago

@hostep yes, I do agree that upgrade should be done at the last step however sometime we may deploy some new backend modules,....which should run upgrade DB but shouldn't touch Varnish. Automatic detection can be hard but maybe we should provide an option to flush Varnish or not when we run upgrade DB so the deployment pipeline can decide which strategy they want

ihor-sviziev commented 1 year ago

@onlinebizsoft I think it's not so important to provide such a feature out of the box since it would be needed for small percent of shops. If needed, you always could implement it in your custom extension or apply your custom patch

engcom-Dash commented 1 year ago

Hi @onlinebizsoft ,

As per @hostep Comments ,We are closing the issue for now. Please feel free to reopen it or ask us to reopen.

Thanks!