At Percona Managed Services, we manage Percona for MySQL, MySQL Community, MariaDB, and other software. Sometimes we might need to use mydumper/myloader to restore one or more databases from the production environment to the lower environment for testing. 

The automated restore process ran well until one day, we got the error below.

0. The error we face is below, myloader failed to restore view with function.

After checking the db…vw_##schema-view.sql.gz file, the view definition, we found it calls a function that is not created when restored, therefore, the error above triggers.

We reproduce this error with the same mydumper 0.12.7-3 and Percona Server for MySQL 8.0.33 version installed on the test server:

1. We create the test table, view, and function as below.

2. Take the mydumper backup

3.  We simulate the restore with a change of the DB name

Yes, the same error as we got before.

4.  One possible solution is to add:

Add the content (to be specific, the create function part) of file testdb-schema-post.sql 

 to the top of the file testdb.vw_testtab_detail-schema-view.sql.

Then, run the myloader command to restore again. This will create the function first and create the view depending on the function later.

We run myloader again, it’s good

Another option is to upgrade mydumper(myloader) to the latest version, as it’s a known issue and discussed here:

https://github.com/mydumper/mydumper/issues/755

But we need to upgrade mydumper on both the source server where the backup was taken, and the target server where the database we are going to restore to.

Otherwise, we might get the error below if we are trying to restore the backup with the latest mydumper v0.16.1-2, as it cannot restore the backup taken by version 0.12.7-3,

Conclusion

Hope this is helpful for your daily MySQL and MariaDB management or if you face the same issue as I did.

As mentioned in the beginning, Percona offers Support and Managed Services for Community versions of MariaDB.

At the same time, we encourage MariaDB users to explore Percona Server for MySQL as an alternative.

Should you make the decision to migrate to Percona Software for MySQL, our experts will assist throughout the migration process and support you after the migration is complete.

 

Contact us to discuss migration options

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments