Skip to content

DOLT_BACKUP Restore Requires Existing Database Context and Service Restart to Recognize New Database #10136

@lihh1992

Description

@lihh1992

As shown below, there is a backup file of a Dolt database named metabase_init in the directory /opt/dolt_backup on the host 192.168.48.6:

[root@instance-04cghrqg-1 dolt_backup]# pwd
/opt/dolt_backup
[root@instance-04cghrqg-1 dolt_backup]# ls -alh
total 696K
drwxr-xr-x   3 root root  4.0K Nov 26 15:02 .
drwxr-xr-x. 16  501 games 4.0K Oct 21 18:35 ..
drwxr-xr-x   3 root root  4.0K Nov 26 15:02 metabase_init
-rw-r--r--   1 root root  683K Nov 26 15:02 metabase_init.zip
[root@instance-04cghrqg-1 dolt_backup]# tree
.
├── metabase_init
│   ├── LOCK
│   ├── manifest
│   ├── oldgen
│   └── vgk9hjquet44n1nhldg1in1449sib2b5
└── metabase_init.zip

2 directories, 4 files

Now, using the MySQL client on the local machine to connect to the database and attempting to restore the data using DOLT_BACKUP, an error "Empty database name." is reported:

PS E:\LSX17\Downloads> mysql -h 192.168.48.6 -P3306 -uuser1 -ppass1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 263
Server version: 8.0.33 Dolt

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CALL DOLT_BACKUP('restore', 'file:///opt/dolt_backup/metabase_init', 'test_d');
ERROR 1105 (HY000): Empty database name.

It seems that we need to use a database first:

mysql> use insight_jobadmin;
Database changed
mysql> CALL DOLT_BACKUP('restore', 'file:///opt/dolt_backup/metabase_init', 'test_d');
+--------+
| status |
+--------+
|      0 |
+--------+
1 row in set (0.04 sec)

mysql> use test_d;
ERROR 1049 (HY000): database not found: test_d

Checking the database files on the host 192.168.48.6:

[root@instance-04cghrqg-1 test_d]# pwd
/opt/dolt_data/test_d

[root@instance-04cghrqg-1 test_d]# dolt status
Warning: Unknown global config option 'sqlserver.cluster.dolt_cluster_role'. Use `dolt config --global --unset sqlserver.cluster.dolt_cluster_role` to remove.
Warning: Unknown global config option 'sqlserver.cluster.dolt_cluster_role_epoch'. Use `dolt config --global --unset sqlserver.cluster.dolt_cluster_role_epoch` to remove.
Error 1049 (HY000): database not found: test_d

[root@instance-04cghrqg-1 test_d]# tree -a
.
└── .dolt
    ├── config.json
    ├── noms
    │   ├── LOCK
    │   ├── manifest
    │   ├── oldgen
    │   └── vgk9hjquet44n1nhldg1in1449sib2b5
    ├── repo_state.json
    └── temptf

4 directories, 5 files

After restarting the Dolt service:

[root@instance-04cghrqg-1 test_d]# ps uax | grep dolt
root      4958  0.0  0.0 112820  2340 pts/0    S+   09:55   0:00 grep --color=auto dolt
root      6947  1.6  1.4 2803964 476196 pts/0  Sl   Nov26  18:53 dolt sql-server --config config.yaml

[root@instance-04cghrqg-1 test_d]# kill -15 6947

[root@instance-04cghrqg-1 test_d]# ps uax | grep dolt
root      6010  0.0  0.0 112820  2344 pts/0    S+   09:56   0:00 grep --color=auto dolt

[root@instance-04cghrqg-1 test_d]# cd ../../
[root@instance-04cghrqg-1 opt]# cd dolt_data/

[root@instance-04cghrqg-1 dolt_data]# sh start.sh 
[root@instance-04cghrqg-1 dolt_data]# nohup: appending output to ‘nohup.out’

[root@instance-04cghrqg-1 dolt_data]# cd test_d
[root@instance-04cghrqg-1 test_d]# dolt status
Warning: Unknown global config option 'sqlserver.cluster.dolt_cluster_role'. Use `dolt config --global --unset sqlserver.cluster.dolt_cluster_role` to remove.
Warning: Unknown global config option 'sqlserver.cluster.dolt_cluster_role_epoch'. Use `dolt config --global --unset sqlserver.cluster.dolt_cluster_role_epoch` to remove.
On branch main

Changes not staged for commit:
  (use "dolt add <table>" to update what will be committed)
  (use "dolt checkout <table>" to discard changes in working directory)
	modified:         __DATABASE__test_d

Untracked tables:
  (use "dolt add <table>" to include in what will be committed)
	new table:        QRTZ_SIMPLE_TRIGGERS
    ......

[root@instance-04cghrqg-1 test_d]# cat /opt/dolt_data/start.sh 
nohup dolt sql-server --config config.yaml &

Now the client can recognize the new database test_d:

mysql> use test_d;
No connection. Trying to reconnect...
Connection id:    2
Current database: *** NONE ***

Database changed

First question: Does CALL DOLT_BACKUP('restore', 'file:///opt/dolt_backup/metabase_init', 'test_d'); have to be executed within an existing database? This doesn't seem very reasonable.

Second question: It appears that the database restored from the backup requires a restart of the Dolt service to be recognized. From a business perspective, restarting is almost unacceptable. So, is there any other way to make the database immediately recognizable after the restore is completed?

My entire goal is: to create a database in the existing Dolt service from the data in the backup, and have it immediately recognized to provide services for applications without affecting the existing ones. Therefore, the two issues mentioned above make this process unworkable. Are there any alternative methods?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions