From: Date: June 23 2008 5:01pm Subject: bzr push into mysql-6.0-backup branch (oystein.grovlen:2638) Bug#36586 List-Archive: http://lists.mysql.com/commits/48339 X-Bug: 36586 Message-Id: <20080623150109.AEB41194@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 2638 Oystein Grovlen 2008-06-23 BUG#36586 Online backup stream library can miss end of a stream. Make sure end-of-stream is detected. Before this fix, a restore of a multi-block backup image would never complete. added: mysql-test/r/backup_multi_blocks.result mysql-test/t/backup_multi_blocks.test modified: mysql-test/lib/mtr_report.pl sql/backup/stream_v1_transport.c === modified file 'mysql-test/lib/mtr_report.pl' --- a/mysql-test/lib/mtr_report.pl 2008-05-05 19:38:05 +0000 +++ b/mysql-test/lib/mtr_report.pl 2008-06-23 14:53:35 +0000 @@ -333,6 +333,13 @@ sub mtr_report_stats ($) { ( /Backup:/ or /Restore:/ or /Can't open the online backup progress tables/ ) or + + # Filter expected Restore error in backup_multi_blocks + ($testname eq 'main.backup_multi_blocks') and + ( + /Restore: Error when reading summary section of backup image/ + ) or + # The tablespace test triggers error below on purpose ($testname eq 'main.backup_tablespace') and ( === added file 'mysql-test/r/backup_multi_blocks.result' --- a/mysql-test/r/backup_multi_blocks.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/r/backup_multi_blocks.result 2008-06-23 14:53:35 +0000 @@ -0,0 +1,40 @@ +DROP DATABASE IF EXISTS mysqltest; +Creating database and tables ... +CREATE DATABASE mysqltest; +USE mysqltest; +CREATE TABLE t1 (a LONGTEXT) ENGINE=MYISAM; +Inserting data ... +USE mysqltest; +INSERT INTO t1 VALUES ("text"); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +UPDATE t1 SET a=CONCAT(a,a); +SELECT LENGTH(a) FROM t1; +LENGTH(a) +32768 +Performing backup ... +BACKUP DATABASE mysqltest TO 'test.ba'; +backup_id +#; +DROP DATABASE mysqltest; +Performing restore ... +RESTORE FROM 'test.ba'; +ERROR HY000: Error when reading summary section of backup image +Checking contents of restore ... +SELECT LENGTH(a) FROM t1; +LENGTH(a) +CHECKSUM TABLE t1; +Table Checksum +mysqltest.t1 0 +Clean-up +DROP DATABASE mysqltest; === added file 'mysql-test/t/backup_multi_blocks.test' --- a/mysql-test/t/backup_multi_blocks.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/t/backup_multi_blocks.test 2008-06-23 14:53:35 +0000 @@ -0,0 +1,51 @@ +--source include/not_embedded.inc +--source include/have_debug.inc + +# Run test only on 64-bit platforms until BUG#36624 has been fixed. +--source include/have_64bit.inc + + +# Test that it is possible to restore backups of tables with more than +# a single block of data. Until BUG#36624 is fixed, restore will fail +# on 64-bit platforms. Test is temporarily modified to expect this +# failure. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest; +--enable_warnings + +--echo Creating database and tables ... +CREATE DATABASE mysqltest; +USE mysqltest; + +CREATE TABLE t1 (a LONGTEXT) ENGINE=MYISAM; + +--echo Inserting data ... +USE mysqltest; +INSERT INTO t1 VALUES ("text"); +LET $1=13; +WHILE ($1) +{ + UPDATE t1 SET a=CONCAT(a,a); + DEC $1; +} +SELECT LENGTH(a) FROM t1; + +--echo Performing backup ... +--replace_column 1 #; +BACKUP DATABASE mysqltest TO 'test.ba'; + +DROP DATABASE mysqltest; + +# Perform restore. Will fail on 64-bit platforms due to BUG#36224 +--echo Performing restore ... +--error ER_BACKUP_READ_SUMMARY +RESTORE FROM 'test.ba'; + +--echo Checking contents of restore ... +SELECT LENGTH(a) FROM t1; +CHECKSUM TABLE t1; + +--echo Clean-up +DROP DATABASE mysqltest; +--remove_file $MYSQLTEST_VARDIR/master-data/test.ba === modified file 'sql/backup/stream_v1_transport.c' --- a/sql/backup/stream_v1_transport.c 2007-12-03 20:28:32 +0000 +++ b/sql/backup/stream_v1_transport.c 2008-06-23 14:53:35 +0000 @@ -1480,7 +1480,10 @@ int bstream_read_part(backup_stream *s, saved= *data; data->end= data->begin + howmuch; - as_read(&s->stream,data,buf); + if (as_read(&s->stream, data, buf) == BSTREAM_EOS) + { + s->state= EOS; + } s->buf.begin += data->begin - saved.begin; s->buf.pos= s->buf.begin;