#At file:///home/og136792/mysql/shared/mysql-6.0-backup-1/
2638 Oystein Grovlen 2008-06-17
BUG#36586 Online backup stream library can miss end of a stream.
Make sure end-of-stream is detected.
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
per-file messages:
mysql-test/lib/mtr_report.pl
Filter out expected restore error from master.err.
mysql-test/r/backup_multi_blocks.result
Output for new test.
mysql-test/t/backup_multi_blocks.test
Test that a restore of a multi-block backup is successful.
Prior to this bug fix, test would hang.
Until 36624 is fixed the restore in this test will fail on 64-bit platforms and
currently the test is written to expect that. (The test is disabled on non-64-bit
platforms).
sql/backup/stream_v1_transport.c
Make sure unexpected end-of-stream is detected in load_buffer()
Have verified that all calls to as_read() now checks for end-of-stream.
=== 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-17 11:28:28 +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-17 11:28:28 +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-17 11:28:28 +0000
@@ -0,0 +1,50 @@
+--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;
=== 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-17 11:28:28 +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;