Skip to content

[Indexes] Product 'version_id' lost last 'auro_increment' value after MySQL restart. #14465

@swnsma

Description

@swnsma

Preconditions

  1. MySQL 5.7.21
  2. Magento CE/EE (Any version. Checked on 2.1.12 and 2.2.3) with Sample Data.
  3. Enabled Flat Tables (BO -> Stores -> Configuration -> Catalog -> Catalog -> Storefront -> Use Flat Catalog Product).
  4. Indexer set to 'UPDATE BY SCHEDULE' mode (BO -> System -> Index Management).
  5. Initial reindex was done and flats already created.
  6. Table catalog_product_attribute_cl is empty.

Steps to reproduce

  1. Go to BO.
  2. Open product edit form (Catalog -> Products -> Product with id №8).
  3. Edit product attribute (e.g. name to 'Test Before Restart MySQL').
  4. Press 'Save'.
  5. Edit 1-2 more product with changing of any attributes.
  6. Check that new records have created in catalog_product_attribute_cl. Remember 'version_id'.
  7. Wait (or execute) crons in next order:
  • indexer_update_all_views;
  • indexer_clean_all_changelogs;
  1. Check that catalog_product_attribute_cl empty.
  2. Check product on frontend - changes have applied.
  3. Restart MySQL.
  4. Edit the product. Change name to 'Test After Restart MySQL'
  5. Run Cron. E.G. php bin/magento cron:run.
  6. Go To Frontend -> Gears -> Bags.
  7. Find product with id №8.

Expected result

  1. Product has name 'Test After Restart MySQL'.

Actual result

  1. Product has name 'Test Before Restart MySQL'.

Additional information

Explanation.
From the MySQL documentation.

InnoDB uses the in-memory auto-increment counter as long as the server runs. When the server is stopped and restarted, InnoDB reinitializes the counter for each table for the first INSERT to the table, as described earlier.

As result, in case of MySQL restart while catalog_product_attribute_cl table is empty, auto_increment value will be dropped to the initial value (0), but last value of 'version_id' in mview_state will be the same as before MySQL restart.
In that case any 'changelog' event will not be processed until 'version_id' in catalog_product_attribute_cl will not be greater or equal that version_id in mview_state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.1.xThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions