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

catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue #18387

Closed
gwharton opened this issue Oct 4, 2018 · 19 comments
Assignees
Labels
Component: Catalog Event: squashtoberfest Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@gwharton
Copy link
Contributor

gwharton commented Oct 4, 2018

Preconditions

  1. Magento 2.3-develop
  2. Sample data deployed (in order to easily have several test images in store)

Steps to reproduce

  1. php bin/magento catalog:images:resize

Expected result

  1. All 3422 images should be processed

Actual result

  1. Only 801 images are processed.
developer@reedling$ php bin/magento catalog:images:resize
 801/3422 [======>---------------------]  23% 14 mins 58.0 MiB  | /w/s/wsh12-red_main_2.jpg
Product images resized successfully
developer@reedling$

In my 2.2.6 development store which has 140 images, it always stops after exactly 100.

I can reproduce this issue on both 2.3-develop and 2.2.6.

Possible underlying Magento/Framework/DB/Query/Generator issue.

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 4, 2018

Hi @gwharton. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@gwharton do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 4, 2018
@gwharton
Copy link
Contributor Author

gwharton commented Oct 4, 2018

Can't use engcom test instances as need terminal and sample data.

However 100% reproducable using above steps on newly deployed 2.3-develop from git, and 2.2.6 existing installs (two 2.2.6 deployments both show same issue)

@Fazzke
Copy link

Fazzke commented Oct 6, 2018

#squashtoberfest

@magento-engcom-team
Copy link
Contributor

@Fazzke thank you for joining. Please accept team invitation here and self-assign the issue.

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 6, 2018

Hi @Fazzke. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@Fazzke Fazzke added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Oct 6, 2018
@Fazzke
Copy link

Fazzke commented Oct 6, 2018

@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @Fazzke. Thank you for your request. I'm working on Magento 2.2-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @Fazzke, here is your Magento instance.
Admin access: https://i-18387-2-2-develop.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@vpodorozh vpodorozh self-assigned this Oct 23, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 23, 2018

Hi @vpodorozh. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 25, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix getCountAllProductImages select and cover class with unit tests.
@vpodorozh
Copy link
Contributor

vpodorozh commented Oct 25, 2018

@gwharton - all your images are processed correctly.
However, there is a problem with total images count calculation select statement here: 6a6079d#diff-1c09f9f539ac83d47bf95f4f1ef90457R78
Distinct by image path is not used in count(*).

So, in case you will execute the next SQL:
select count(DISTINCT value) from catalog_product_entity_media_gallery as g where disabled = 0;
You will get "801" - the actual amount of your images.

I've fixed total images calculation my PR.

@vpodorozh vpodorozh removed their assignment Oct 25, 2018
vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 25, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix getCountAllProductImages select and cover class with unit tests.

(cherry picked from commit 6a6079d)
@gwharton
Copy link
Contributor Author

gwharton commented Oct 25, 2018

Something doesnt sound right to me there.

I have 139 images in my pub/media/catalog/product folder
MYSQL says I have 139 images
But resize only resizes the first 100

developer@reedling:~/html$ php bin/magento catalog:images:resize                               
100/139 [====================>-------]  71% 59 secs 64.0 MiB    | /s/h/shell_omala_s2_gx_100.jpg
Product images resized successfully.
developer@reedling:~/html$ find pub/media/catalog -name *.jpg | grep -v cache | grep -v resized | grep -v placeholder | wc -l
139
developer@reedling:~/html$ mysql dev_magento
mysql> select count(DISTINCT value) from catalog_product_entity_media_gallery as g where disabled = 0;
+-----------------------+
| count(DISTINCT value) |
+-----------------------+
|                   139 |
+-----------------------+
1 row in set (0.00 sec)

mysql> 

@gwharton
Copy link
Contributor Author

Seems to be two issues here as if I do it on a clean 2.2-develop with sample data installed.

developer@reedling:~/dev1$ php bin/magento catalog:images:resize                                                         
 700/3422 [=====>----------------------]  20% 15 mins 54.0 MiB  | /w/s/wsh07-blue_main.jpg
Product images resized successfully.
developer@reedling:~/dev1$ find -L pub/media/catalog -name *.jpg | grep -v cache | grep -v resized | grep -v placeholder | wc -l
725
developer@reedling:~/dev1$ mysql dev1_magento
mysql> select count(DISTINCT value) from catalog_product_entity_media_gallery as g where disabled = 0;
+-----------------------+
| count(DISTINCT value) |
+-----------------------+
|                   723 |
+-----------------------+
1 row in set (0.00 sec)

mysql> 

I'm willing to accept that there are two images in the pub/media folder that don't correspond to an entry in the database which exlpains the discrepancy between 723 and 725. 723 being the number of images correctly configured.

The images resize command wrongly calculates the total as 3422 which looks like the issue you are fixing with your PR's.

The image resize command also stops at 700 which is a separate bug. This second problem seems to be related to the batching with the batchSelectIterator inside the getAllProductImages() call of /app/code/Magento/Catalog/Model/ResourceModel/Product/Image.php

The default batch size is 100, and it looks like it doesnt process the last batch.

So in my first example it processes the first 100, then skips the last 39. And in my second example it processes the first (7*100) and then skips the last 23.

@gwharton gwharton added the Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release label Oct 25, 2018
@gwharton
Copy link
Contributor Author

Perhaps this second bug is not present in 2.3-develop as if you run the same on that, you get 801 images processed of 801 images configured (albeit reporting that there are 3422 images in total (total fixed by your PR))

@vpodorozh
Copy link
Contributor

@gwharton - thank you for your response and explanations.
I've developed the fix for 2.3-develop branch so I've not reproduced the second problem, which is actually critical.
WIll take a look at 2.2-develop branch on the next week.

vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 25, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix code style;
vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 27, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix unit test - now it can test also not only full batches, but partial as well (139 images with batch size 100);
vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 27, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix unit test - now it can test also not only full batches, but partial as well (139 images with batch size 100);
vpodorozh added a commit to vpodorozh/magento2 that referenced this issue Oct 27, 2018
catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue
- fix code style;

(cherry picked from commit 466daaa)
@TomashKhamlai TomashKhamlai self-assigned this Nov 15, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 15, 2018

Hi @TomashKhamlai. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@ghost
Copy link

ghost commented Nov 30, 2018

Hi @gwharton , thank you for you report, this issue has already fixed in 2.3-develop branch, and will be available on 2.3.1 release.

@ghost ghost closed this as completed Nov 30, 2018
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 31, 2019
magento-engcom-team added a commit that referenced this issue Jan 31, 2019
…ulates incorrectly #18387 #18809

 - Merge Pull Request #18809 from vpodorozh/magento2:2.2-develop-18387-catalog-images-resize
 - Merged commits:
   1. f114f2a
   2. 95eeb9f
   3. 84590de
   4. 4653d3e
   5. d2e5345
   6. 2539a71
   7. 76bd089
   8. b81b550
   9. 051d82d
   10. 10a1a88
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Event: squashtoberfest Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants