Bug #36475 Default driver throws errors on deleted rows
Submitted: 2 May 2008 15:06 Modified: 14 May 2008 16:37
Reporter: Chuck Bell Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Backup Severity:S2 (Serious)
Version:6.0.5 OS:Any
Assigned to: Chuck Bell CPU Architecture:Any
Tags: Contribution

[2 May 2008 15:06] Chuck Bell
Description:
The MySQL backup default driver does not properly process rows that have been marked as deleted. Instead of processing the row, it throws an error which can cause a core dump on debug builds:

c:\mysql\bin>mysqld --console -uroot --datadir=c:\\mysql\\data --basedir=c:\\mys
ql --binlog-format=row --log-bin=mysql-bin --server-id=1
080502  9:54:12  InnoDB: Started; log sequence number 0 36070485
080502  9:54:12 [Note] Event Scheduler: Loaded 0 events
080502  9:54:12 [Note] mysqld: ready for connections.
Version: '6.0.6-alpha-debug-log'  socket: ''  port: 3306  MySQL-new-rpl clone
080502  9:54:20 [Note] Backup: Starting backup process
080502  9:54:20 [Note] Backup: Backing up selected databases
080502 10:02:46 [ERROR] Backup: Error when polling Default backup driver for its
 data
Assertion failed: !table->file || table->file->inited == handler::NONE, file .\s
ql_base.cc, line 1422
080502 10:03:06 - mysqld got exception 0x80000003 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8388572
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337726 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x3c9fb48
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
00584113    mysqld.exe!???
00A45D39    mysqld.exe!???
00A5DC7E    mysqld.exe!???
00A46896    mysqld.exe!???
00A5D8A0    mysqld.exe!???
00A5D869    mysqld.exe!???
00A58F1B    mysqld.exe!???
00A41EAB    mysqld.exe!???
00A3831F    mysqld.exe!???
0062DB0A    mysqld.exe!???
0062D9EC    mysqld.exe!???
0062D715    mysqld.exe!???
00961C83    mysqld.exe!???
0089F81D    mysqld.exe!???
00A48571    mysqld.exe!???
00A48517    mysqld.exe!???
76884911    kernel32.dll!BaseThreadInitThunk()
7709E4B6    ntdll.dll!RtlInitializeExceptionChain()
7709E489    ntdll.dll!RtlInitializeExceptionChain()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 03C55898=default driver locking thread
thd->thread_id=2
thd->killed=KILL_CONNECTION
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

How to repeat:
Use the attached database and run:

BACKUP DATABASE systest1 TO 's.bak';

...and observe the mayhem.

Suggested fix:
Change the default driver to ignore deleted records as errors. Allow them to be skipped.

===== be_default.cc 1.12 vs edited =====
--- 1.12/sql/backup/be_default.cc       2008-03-04 11:08:40 -05:00
+++ edited/be_default.cc        2008-05-02 10:02:48 -04:00
@@ -363,6 +402,9 @@
     cur_blob= 0;
     cur_table->use_all_columns();
     last_read_res = hdl->rnd_next(cur_table->record[0]);
+    while ((last_read_res == HA_ERR_RECORD_DELETED) &&
+           (last_read_res != HA_ERR_END_OF_FILE))
+      last_read_res = hdl->rnd_next(cur_table->record[0]);
     DBUG_EXECUTE_IF("SLEEP_DRIVER", sleep(4););
     /*
       If we are end of file, stop the read process and signal the
[6 May 2008 17:47] Chuck Bell
This bug is a duplicate of BUG#35249. The solution shown in this bug report is valid and will be used to solve both bugs.
[14 May 2008 16:37] Chuck Bell
Problem solved with BUG#35249 patch.