Commit 95e99e12 authored by Praveenkumar Hulakund's avatar Praveenkumar Hulakund

Bug#11759519 - INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA

               LOCAL AND IMPORT ERRORS

Description:
-----------
This bug happens due to the fact that current algorithm is designed
that in the case of LOCAL load of data, in case of the error, the
remaining part of the file is read in order to return the proper
error message to the client side.

But, the problem with current implementation is that data stream
for the client side is cleared only in the case where line delimiters
exist, which is not a case with, for example fixed width
fields.

Fix:
----
Ported patch provided by Sinisa Milivojevic n bug report for this
issue to 5.5+ versions.

As part of this patch code is changed to clear the data stream
by calling new member function "READ_INFO::skip_data_till_eof".
parent c8b8d009
......@@ -520,3 +520,15 @@ LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt' INTO TABLE t1;
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
End of 5.1 tests
#
# Bug#11759519 INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA LOCAL AND IMPORT ERRORS
#
SET @old_mode= @@sql_mode;
CREATE TABLE t1 (fld1 INT);
SET sql_mode='strict_all_tables';
# Without fix, load data hangs forever.
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/mysql' REPLACE INTO TABLE t1
FIELDS TERMINATED BY 't' LINES TERMINATED BY '';
Got one of the listed errors
SET @@sql_mode= @old_mode;
DROP TABLE t1;
......@@ -635,3 +635,24 @@ create table t1(a point);
drop table t1;
--echo End of 5.1 tests
--echo #
--echo # Bug#11759519 INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA LOCAL AND IMPORT ERRORS
--echo #
SET @old_mode= @@sql_mode;
CREATE TABLE t1 (fld1 INT);
--copy_file $EXE_MYSQL $MYSQLTEST_VARDIR/mysql
SET sql_mode='strict_all_tables';
--echo # Without fix, load data hangs forever.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,1000
eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/mysql' REPLACE INTO TABLE t1
FIELDS TERMINATED BY 't' LINES TERMINATED BY '';
SET @@sql_mode= @old_mode;
--remove_file $MYSQLTEST_VARDIR/mysql
DROP TABLE t1;
......@@ -56,6 +56,9 @@ XML_TAG::XML_TAG(int l, String f, String v)
}
#define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache))
#define PUSH(A) *(stack_pos++)=(A)
class READ_INFO {
File file;
uchar *buffer, /* Buffer for read text */
......@@ -110,6 +113,15 @@ class READ_INFO {
either the table or THD value
*/
void set_io_cache_arg(void* arg) { cache.arg = arg; }
/**
skip all data till the eof.
*/
void skip_data_till_eof()
{
while (GET != my_b_EOF)
;
}
};
static int read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
......@@ -534,8 +546,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if (error)
{
if (read_file_from_client)
while (!read_info.next_line())
;
read_info.skip_data_till_eof();
#ifndef EMBEDDED_LIBRARY
if (mysql_bin_log.is_open())
......@@ -1392,10 +1403,6 @@ READ_INFO::~READ_INFO()
}
#define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache))
#define PUSH(A) *(stack_pos++)=(A)
inline int READ_INFO::terminator(char *ptr,uint length)
{
int chr=0; // Keep gcc happy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment