-
Type: Task
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Execution Team 2022-04-04, Execution Team 2022-04-18
See the design for details:
A new command will be introduced, renameDatabaseForRestore, that can only be used during a restore after all of the desired oplog entries have been replayed (after this step). This is to avoid having to rewrite any oplog entries with the new database names. The command will have two parameters, from: <string> and to: <string>.
from and to will be validated to ensure they are valid database names. An internal database (admin, local or config) cannot be renamed. If the database to already exists, the command will fail.
The command will perform the following procedure:
- Close the catalog.
- Open a WT_CURSOR on the _mdb_catalog.wt table. Iterate over the records and modify the namespace field for any collection in the from database.
- If the server is running with directoryperdb, then the tables in the from directory will have to be moved to the to directory in the dbpath. The table’s path relative to the dbpath is stored in the WiredTiger metadata and will need to be modified as well.
- The WT_SESSION::rename() command has a few known bugs and is not used by the server.
- The alternative is to extract the collection and index metadata, then use WT_SESSION::drop() with the remove_files=false option, move the tables to the to directory, modify the directory name in the extracted metadata and use WT_SESSION::create() with the import option.
- After this procedure, the from directory will be empty and removed.
- Open the catalog.
- Update the documents in the system.views collection to the new database name.
- depends on
-
SERVER-62607 Create the renameDatabaseForRestore command
- Closed
-
SERVER-64603 New RenameDatabaseForRestore Command Skeleton
- Closed
- is duplicated by
-
SERVER-62607 Create the renameDatabaseForRestore command
- Closed