Bug 1166786 - mariadb in 15.2 cannot restore a dump made with 15.1
Summary: mariadb in 15.2 cannot restore a dump made with 15.1
Status: RESOLVED FIXED
: 1168493 (view as bug list)
Alias: None
Product: openSUSE Distribution
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Leap 15.2
Hardware: Other Other
: P3 - Medium : Normal (vote)
Target Milestone: ---
Assignee: Danilo Spinella
QA Contact: E-mail List
URL:
Whiteboard: https://jira.suse.com/browse/DOCTEAM-681
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-16 13:39 UTC by Stefan Seyfried
Modified: 2022-09-20 10:01 UTC (History)
6 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
dump file which cannot be restored (101.54 KB, application/octet-stream)
2020-03-16 13:39 UTC, Stefan Seyfried
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Seyfried 2020-03-16 13:39:58 UTC
Created attachment 832905 [details]
dump file which cannot be restored

How to reproduce:

* install 15.1, "minimal server"
* zypper in mariadb
* rcmysql start
* mysql_secure_installation # default answers to everyhting, set root password
* create .my.cnf with root password
* mysqldump --all-databases -pmysql > 
* zypper --releasever 15.2 ref
* zypper --releasever 15.2 -v dup --no-r
* reboot
* rcmysql stop
* rm -r /var/lib/mysql
* rcmysql start
* mysql_secure_installation
* mysql -u root < /root/opensuse-15.1.sql

Result:
ERROR 1050 (42S01) at line 804: Table 'user' already exists
Comment 1 Andreas Stieger 2020-03-16 14:26:55 UTC
You are trying to load a dump that already contains the user table. This is automatically created when you start the server on an empty repository. You need to exclude it from the dump or the load. This would happen for any other migration done, including from 15.1 to 15.1 (same version) while deleting the data directory.
Comment 2 Per Jessen 2020-03-16 14:36:15 UTC
(In reply to Andreas Stieger from comment #1)
> You are trying to load a dump that already contains the user table. This is
> automatically created when you start the server on an empty repository. You
> need to exclude it from the dump or the load. 

Presumably the database dump contains a DROP TABLE IF EXISTS `user` ? Looking at one of mine, it does.
Comment 3 Stefan Seyfried 2020-03-16 15:20:40 UTC
15.1 can restore the exact same dump, 15.2 cannot

This is the offending line 804

797 --
798 -- Table structure for table `user`
799 --
800 
801 DROP TABLE IF EXISTS `user`;
802 /*!40101 SET @saved_cs_client     = @@character_set_client */;
803 /*!40101 SET character_set_client = utf8 */;
804 CREATE TABLE `user` (
805   `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
806   `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',

If this bug is indeed "invalid" then let's hope for SUSE support that SLES users don't get this update ;-)
Comment 4 Stefan Seyfried 2020-03-16 15:22:58 UTC
(In reply to Per Jessen from comment #2)
> (In reply to Andreas Stieger from comment #1)
> > You are trying to load a dump that already contains the user table. This is
> > automatically created when you start the server on an empty repository. You
> > need to exclude it from the dump or the load. 
> 
> Presumably the database dump contains a DROP TABLE IF EXISTS `user` ?
> Looking at one of mine, it does.

I deliberately added the dump file so that interested people could test.

I'm investigating the effort of switching to postgres now.
Comment 5 Andreas Stieger 2020-03-16 15:34:04 UTC
(In reply to Stefan Seyfried from comment #3)
> If this bug is indeed "invalid" then let's hope for SUSE support that SLES
> users don't get this update ;-)

Oh well...
Comment 6 Kristyna Streitova 2020-04-02 17:54:45 UTC
This seems to be a bug and I reported it upstream as https://jira.mariadb.org/browse/MDEV-22127

The problem is that in MariaDB 10.4 `user` table is a view that needs to be dropped as well before the table `user` is created.

A quick workaround is to add "/*!50001 DROP VIEW IF EXISTS `user`*/;" before the 
CREATE TABLE `user` statement. Then the dump can be restored without any problems.
Comment 7 Danilo Spinella 2021-11-17 14:04:27 UTC
By adding `--add-drop-database` when calling mysqldump, the dump can be imported in MariaDB 10.4 and later versions. 

The optimal solution would be to automatically make the dump work without adding `-add-drop-database` and this is currenctly tracket by the upstream bug.However,, it has not received any work since it has been reported 1 year and a half ago and it has been marked as "Stalled".
Comment 8 Christoph Wickert 2022-07-08 12:04:03 UTC
I added '--add-drop-database' to the MySQL/MariaDB instructions in the SLE upgrade guide, see https://github.com/SUSE/doc-sle/commit/3641f69b60544d112e87fc59c3d26b75be76016c

Any reasons to not do this?
Comment 9 Christoph Wickert 2022-08-02 09:53:19 UTC
Danilo, I've closed https://jira.suse.com/browse/DOCTEAM-681 now. If there is anything you want me to update the documentation – either remove '--add-drop-database' again or change something else – please set NEEDINFO for me.
Comment 10 Danilo Spinella 2022-08-22 15:47:41 UTC
(In reply to Christoph Wickert from comment #9)
> Danilo, I've closed https://jira.suse.com/browse/DOCTEAM-681 now. If there
> is anything you want me to update the documentation – either remove
> '--add-drop-database' again or change something else – please set NEEDINFO
> for me.

Thank you Christoph for adding it and for the update.
Comment 11 Danilo Spinella 2022-09-19 09:41:00 UTC
The upstream bug hasn't seen any update in the last year and we already have a documented workaround. I am closing this bug as fixed.
Comment 12 Danilo Spinella 2022-09-20 10:01:47 UTC
*** Bug 1168493 has been marked as a duplicate of this bug. ***