Hi Ingo,
SATATUS: Approved.
SUGGESTION
----------
I think that the new requirement that a backup engine must correctly
save/restore auto_increment value for each table should be documented
somewhere, but I don't know where :( I suggest adding a note to the bug for
the docs team, so that when time comes we will make some decision on how to
document this.
COMMENT: This is a near perfect patch! :)
Ingo Struewing wrote:
> #At file:///home2/mydev/bzrroot/mysql-6.0-bug47484-2/ based on
> revid:charles.bell@stripped
>
> 2879 Ingo Struewing 2009-10-23
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
>
> When implementing the new locking scheme for RESTORE,
> the table's auto_increment values won't be restored.
> The new scheme contains TRUNCATE, which resets the
> auto_increment values to zero. This will lead to a
> "duplicate key" error on the next attempt to insert
> an auto_increment value, at least for the InnoDB
> storage engine.
>
> This patch arranges for a reset of the values to
> what they were at backup time. The auto_increment
> value of each table is stored at the end of the
> table data stream in its own chunk.
>
> Note that this is done for the default- and
> consistent snapshot drivers only. The MyISAM native
> driver restores the value on its own already.
>
> Note that there is a chance that the restored
> auto_increment value can be higher than at the
> validation point of BACKUP. Concurrent DML on a table
> backed up with the consistent snapshot driver can
> increase the auto_increment value before the driver
> reads it. Since we do not guarantee gap free
> auto_increment values, I consider this as acceptable.
> At least this patch assures that the values cannot be
> lower.
>
> Note that the patch does also contain a fix to the
> MEMORY storage engine. ha_heap::reset_auto_increment()
> assigned the value incorrectly. This has not been
> noticed yet because the only use case of the method
> was to reset the value to zero.
> @ mysql-test/suite/backup/r/backup_auto_incr.result
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> New test result.
> @ mysql-test/suite/backup/t/backup_auto_incr.test
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> New test case.
> @ sql/backup/be_default.cc
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> Added write and read operations for auto_increment values
> to the table data stream writer/reader objects.
> @ sql/backup/be_default.h
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> Added AUTO_INCR buffer type.
> @ storage/heap/ha_heap.cc
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> Fixed the value assignment to HP_SHARE::auto_increment
> in ha_heap::reset_auto_increment().
> @ storage/heap/hp_open.c
> Bug#47484 - Online Backup: Restore does not
> set the auto_increment value correctly
> Added DBUG.
>
> added:
> mysql-test/suite/backup/r/backup_auto_incr.result
> mysql-test/suite/backup/t/backup_auto_incr.test
> modified:
> sql/backup/be_default.cc
> sql/backup/be_default.h
> storage/heap/ha_heap.cc
> storage/heap/hp_open.c