Skip to content

Database backup doesn't include triggers #9036

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

Closed
domeglic opened this issue Mar 28, 2017 · 8 comments
Closed

Database backup doesn't include triggers #9036

domeglic opened this issue Mar 28, 2017 · 8 comments
Assignees
Labels
bug report 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: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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

@domeglic
Copy link

domeglic commented Mar 28, 2017

Preconditions

Magento CE 2.1.5, PHP 7.0.15, MariaDB 10.0.29.
Have Index in scheduled mode.

Steps to reproduce

  1. Do a database backup with setup:backup --db.
  2. Do a database restore with setup:rollback -d.

Expected result

Database is restored and includes triggers.

Actual result

Database is missing triggers, so indexing doesn't work correctly.

I noticed this problem after several product changes failed to show in the front. I realized the index was not updated and after some debugging found that there were no triggers.
I tried switching index mode to realtime and saving the product so the changes would appear. When switching back to scheduled the triggers were recreated.
I could reliably reproduce the problem afterwards which leads me to assume the problem is in the backup CLI command.

Short way to reproduce:

  1. Magento CE 2.1.8
  2. Create empty test trigger:
    mysql> CREATE TRIGGER test_trigger AFTER INSERT ON catalog_product_entity FOR EACH ROW BEGIN END;
  3. To make sure that trigger was created:
    mysql> SHOW TRIGGERS;
  4. create backup
    php bin/magento setup:backup --db.
  5. Create New DB:
    CREATE DATABASE magento_backup;
  6. import data form backup
    mysql -u root -p magento_backup < "/var/backups/1506349239_db.sql"
  7. Show trigers from buckup:
    mysql> SHOW TRIGGERS from magento_backup;

Expected result

magento_backup have trigger "test_trigger"

Actual result

magento_backup do not have trigger "test_trigger"

@Stas94
Copy link

Stas94 commented Jul 5, 2017

@domeglic Please add more details to your description of the steps you followed when identifying this issue. Screenshots or logs would be helpful, too.

@domeglic
Copy link
Author

I have added some description but I don't really understand why, the problem seems easy enough to understand and reproduce.

@magento-engcom-team magento-engcom-team added 2.1.x bug report Progress: needs update Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed and removed G1 Passed Progress: needs update labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

We updated description:

Short way to reproduce:

  1. Magento CE 2.1.8
  2. Create empty test trigger:
    mysql> CREATE TRIGGER test_trigger AFTER INSERT ON catalog_product_entity FOR EACH ROW BEGIN END;
  3. To make sure that trigger was created:
    mysql> SHOW TRIGGERS;
  4. create backup
    php bin/magento setup:backup --db.
  5. Create New DB:
    CREATE DATABASE magento_backup;
  6. import data form backup
    mysql -u root -p magento_backup < "/var/backups/1506349239_db.sql"
  7. Show trigers from buckup:
    mysql> SHOW TRIGGERS from magento_backup;

Expected result

magento_backup have trigger "test_trigger"

Actual result

magento_backup do not have trigger "test_trigger"

@magento-engcom-team
Copy link
Contributor

@domeglic, thank you for your report.
We've created internal ticket(s) MAGETWO-78619 to track progress on the issue.

@denisristic
Copy link
Contributor

I'm working on it #SQUASHTOBERFEST

denisristic pushed a commit to denisristic/magento2 that referenced this issue Oct 11, 2017
ADDED getTableTriggersSql() and now it returns valid SQL with drop & create queries for triggers
@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release labels Oct 11, 2017
@magento-engcom-team magento-engcom-team added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Oct 11, 2017
@denisristic
Copy link
Contributor

@ishakhsuvarov this ticket is resolved :)

@magento-team
Copy link
Contributor

Hi @domeglic. Thank you for your report.
The issue has been fixed in #11369 by @denisristic in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 9, 2018
magento-team pushed a commit that referenced this issue Jan 9, 2018
 - Merge Pull Request #11369 from denisristic/magento2:issue-9036
 - Merged commits:
   1. 3255857
   2. f1bcf38
@magento-engcom-team
Copy link
Contributor

Hi @domeglic. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1361 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 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: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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

7 participants