Scenario: Using percona xtrabackup to take online backup and migrate to another VM.
Steps performed:
Run backup command
Run prepare command
Copy the files from this VM to another VM and overwrite the data dictionary of MySQL server (currently in stopped state) in this new VM
Start the MySQL server in this new VM.
Question:
Currently in 3rd step during copy, we don’t copy the redo logs and undo logs assuming that in prepare step, all committed txns changes are applied from redo logs and uncommitted txns changes are rollbacked using undo logs and we have a consistent state, thus they are not needed.
I understand that undo logs are also used for MVCC but does the new server needs these old undo logs since new transactions might never need them and it can create a new undo log after start.
Is our assumption correct or is there a scenario where it is mandatory to copy them?
Thanks @satya.bodapati, I presented my steps in very crude form mentioning only major steps, we do keep backup of current data directory in new server to restore in case of failures.
It looks like you are suggesting to not remove undo/redo log present after running prepare command?
One reason why we wanted to remove these logs were because of their size when taking online backup of large databases, we could make copy faster if they were not needed by not copying them
But my question is still unanswered:
After a successful prepare phase, when we get a transactionally consistent data after applying redo/undo logs, are these logs needed still needed if i intend to use this data for running a new mysql server?
Hi @matthewb, I understand there are no extra files needs to be copied, my question is not that. If you see the above image, this is result after a successful backup and prepare command.
My question is: Since in prepare stage, undo/rego logs are applied to bring the data to consistent state, do i need to copy the undo/redo log files (eg: undo_001, undo_002 etc) to new server? Since this data will be consistent, on startup, there should be no need for this new server to run crash recovery again and it can create new redo/undo logs as new txns run on this new server
Figure out the files that are necessary for server startup
Move tablespaces to exact locations as recorded during backup.
copy-back skips many files that are not necessary for server.
Xtrabackup applies redo log, so there is no need to copy redo files. AFAIR, xtrabackup consumes the redo files and no redo files are left at the end of prepare.
undo tablespaces should be copied. They are still necessary for purging delete marked records.
Ofcourse, all other tablespaces should be copied.
@satya.bodapati , can you explain a little about this statement:
“undo tablespaces should be copied. They are still necessary for purging delete marked records.”
Will the absence of undo logs in this scenario prevent the innodb engine from starting?
We tried the scenarios in our test setup:
Scenario1: Start the new server without copying undo logs.
Scenario2: Start the new server with undo logs.
While scenario 2 works, scenario 1 was also working for us except once when it failed with innodb throwing this error:
[ERROR] InnoDB: Unable to open undo tablespace ‘.//undo001’.
I tried to reproduce it by running an OLTP workload on test server and parallelly taking backup using xtrabackup and restored it on new server without undo logs, but it started without failure.
At this point, it is hard to reproduce the failure of scenario1 since it is working on all my test backups, if you have any ideas, please share
In your statement, since data is in consistent state after prepare, there is no need to restore this deleted record, and it only needs to be purged. If there was something to restore, it would have been done during the prepare phase. When the purge thread starts in the new server, it can safely purge them if it does not find any undo logs for this record.
I read a little on this, that Innodb index only store the latest version of data and any old versions are moved to undo logs which are used for both MVCC and recovery.
Please think of my question as discussion, I understood your advice and will use that but I am curious why it is failing
@Nitish1, can you please explain your reasoning on wanting to skip copying the redo logs? These are not multi-GB files. I’m having trouble understanding why anyone would want to do this in the first place. Do you believe there is some sort of performance gain, or other optimization by not copying these files?