To change the number of undo tablespaces, we need to reinitialize the data directory (dump + restore).
InnoDB should allow changing number of undo tablespaces as a part of restart process.
System tablespace contains InnoDB dictionary tables, doublewrite buffer, change buffer tree
and undo log pages. By allowing this change, InnoDB can reduce the workload on system tablespace.
A prior shutdown with SET GLOBAL innodb_fast_shutdown=0 must be executed before adding the undo log tablespaces.
This is because the undo logs must be empty (no incomplete or XA PREPARE transactions, nothing to be purged) so that the old undo tablespaces can discarded and new ones created.
- Check whether the existing undo log exists. If exists then give the warnings about the slow shutdown and start the server normally.
- If not exist then free the system tablespace rollback segment header page else throw message about slow shutdown and continue the normal server start operation
- Free the system tablespace rollback segment header page of the slots 1...127
- Reset the TRX_SYS page and reinitialize the system tablespace rollback segment slot(0th slot), doublewrite information,
update the binlog info and WSREP info in system rollback segment header page (0th slot page)
Step(3) and (4) should happen within a single mini-transaction
- Delete the old undo tablespaces if any
- Make checkpoint to get rid of old undo tablespace redo log records
- Read the latest MAX_SPACE_ID from dictionary header page
- Create the new specified undo log tablespace and initialize the page0 of all undo tablespaces
Step (7) and Step (8) should happen within a single mini-transaction
- Make the checkpoint again to make sure that next startup or backup reads the undo log tablespaces before
opening the redo log records
- Create the rollback segment for each rollback segment in a round robin fashion