Magento2: SQL error on indexer:reindex 2.2.8

Created on 24 May 2019  路  16Comments  路  Source: magento/magento2

Summary

Catalog indexer is broken when flat mode is turned on.

Information on your environment

Local environment (containerised NGINX with lando) and hosting provided by platform sh

Preconditions (*)

  1. Magento version 2.2.8
  2. Flat category and flat product catalogue enabled (Error doesn't appear with them off)

Steps to reproduce (*)

  1. Updated to 2.2.8 from 2.2.6
  2. Run php bin/magento indexer:reindex

Expected result (*)

  1. Indexer completes successfully

Actual result (*)

  1. Indexer produces SQL error
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition IS NOT NULL)' at line 5, query was: UPDATE `catalog_product_flat_1_tmp_indexer` AS `et`
 LEFT JOIN `eav_attribute_option_value` AS `t0` ON t0.option_id = et.condition AND t0.store_id = 0
 LEFT JOIN `eav_attribute_option_value` AS `ts` ON ts.option_id = et.condition AND ts.store_id = 1
SET `et`.`condition_value` = IFNULL(ts.value, t0.value)
WHERE (condition IS NOT NULL)
Catalog Indexer Clear Description Format is valid Reproduced on 2.2.x Reproduced on 2.3.x

All 16 comments

Hi @danharper83. 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 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

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

  • [ ] yes
  • [ ] no

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

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

Hi @danharper83, here is your Magento instance.
Admin access: https://i-23003-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

I could not replicate this on a Vanilla install.

I think the problem with this query is that the WHERE (condition IS NOT NULL) should be WHERE ('condition' IS NOT NULL)

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition IS NOT NULL)' at line 5, query was: UPDATE `catalog_product_flat_1_tmp_indexer` AS `et` LEFT JOIN `eav_attribute_option_value` AS `t0` ON t0.option_id = et.condition AND t0.store_id = 0 LEFT JOIN `eav_attribute_option_value` AS `ts` ON ts.option_id = et.condition AND ts.store_id = 1 SET `et`.`condition_value` = IFNULL(ts.value, t0.value) WHERE (condition IS NOT NULL)

Hi, can you provide me the instance for 2.2.8 ?

Yeah, try this in app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php line 368:

)->where("`$attributeCode` IS NOT NULL");

@danmooney2 it was an attribute called condition 馃う鈥嶁檪

I deleted the attribute on staging and it indexed successfully, I'm not sure how I can fix the attribute "condition" though.

@danharper83 condition is a reserved word in MySQL/MariaDB. Backticks (`) around the keyword would escape it and it would not be interpreted in a special manner by the parser; I think that's the correct change to make that I referenced above

Hi @engcom-backlog-nazar. 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:

  • [ ] 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 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 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.

HI @danharper83 thank you for you report, this issue has already fixed in 2.3-develop and 2.2-develop branch and available on 2.3.1 release and 2.2.9 release.

@engcom-backlog-nazar I can still replicate this issue on 2.2.9

Reopening as still and issue an 2.2.9 & 2.3.2

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

  • [x] 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.
  • [x] 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.

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

  • [x] 4. Verify that the issue is reproducible on 2.3-develop branch
    Details- Add the comment @magento 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_!

Hello @danharper83
We are not able to reproduce this issue on the lates 2.3-develop branch.
So we have to close this issue.

Was this page helpful?
0 / 5 - 0 ratings