[MXS-1828] multi_loaddata command connection closed by mxs Created: 2018-04-26  Updated: 2018-05-18  Resolved: 2018-05-18

Status: Closed
Project: MariaDB MaxScale
Component/s: readwritesplit
Affects Version/s: 2.2
Fix Version/s: 2.3.0

Type: Bug Priority: Major
Reporter: xiangzhong Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

linux + make debug + mysql 5.6.16


Sprint: MXS-SPRINT-57, MXS-SPRINT-58

 Description   

case like:

    rc = mysql_query(myconn, "DROP TABLE IF EXISTS test_loaddata");
    myquery(rc);
    rc = mysql_query(myconn, "CREATE TABLE test_loaddata (id int(11) AUTO_INCREMENT, names varchar(256), PRIMARY KEY (id))");
    myquery(rc);
 
    strxmov(tmp, "load data local infile '", data_file, "' into table test_loaddata");
    strxmov(cmd, tmp, ";", tmp, NullS);
    while (i < 5)
    {
        int status = 0;
        rc = mysql_query(myconn, cmd);
        myquery(rc);
 
        do {
            if(result = mysql_store_result(myconn)) {
                while((result_row = mysql_fetch_row(result)) != NULL)
                {
                    fields_num = mysql_num_fields(result);
                    for(j = 0; j < fields_num; j++)
                        printf("field[%d] : %s\t", (j+1), result_row[j]);
                    printf("\n");
                }
                mysql_free_result(result);
            }
            else {
                printf("no result set or error\n");
            }
            /* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
            status = mysql_next_result(myconn);
            DIE_IF(status > 0);
            if (status > 0)
                fprintf(stdout, "error is: %s\n", mysql_error(myconn));
        } while (status == 0);
        i++;
    }

loadfile: load_data.txt content
errreeeeee
ttttttttdsss
qqqqqqqqqqqqqqqqqqqqq

by dump traffic between mxs and mysql, we find mxs not send completed packet to db:

2018-04-26 16:49:08.661064 IP 10.101.161.10.35879 > 10.125.198.61.3009: Flags [P.], seq 416:466, ack 211, win 2048, options [nop,nop,TS val 9041746 ecr 1663536599], length 50
        0x0000:  200b c738 a50c 448a 5b33 cdd0 0800 4500  ...8..D.[3....E.
        0x0010:  0066 a2d9 4000 4006 1b8f 0a65 a10a 0a7d  .f..@.@....e...}
        0x0020:  c63d 8c27 0bc1 358c 4efc fa51 afd6 8018  .=.'..5.N..Q....
        0x0030:  0800 7c82 0000 0101 080a 0089 f752 6327  ..|..........Rc'
        0x0040:  8dd7 2e00 0006 6572 7272 6565 6565 6565  ......errreeeeee
        0x0050:  0a74 7474 7474 7474 7464 7373 730a 7171  .ttttttttdsss.qq
        0x0060:  7171 7171 7171 7171 7171 7171 7171 7171  qqqqqqqqqqqqqqqq
        0x0070:  7171 710a                                qqq.

there client actual send more a empty packet at end, but mxs drop this empty packet. and send quit packet to db a little while.

2018-04-26 16:49:39.004077 IP 10.101.161.10.35879 > 10.125.198.61.3009: Flags [P.], seq 466:471, ack 212, win 2048, options [nop,nop,TS val 9072089 ecr 1663566942], length 5
        0x0000:  200b c738 a50c 448a 5b33 cdd0 0800 4500  ...8..D.[3....E.
        0x0010:  0039 a2da 4000 4006 1bbb 0a65 a10a 0a7d  .9..@.@....e...}
        0x0020:  c63d 8c27 0bc1 358c 4f2e fa51 afd7 8018  .=.'..5.O..Q....
        0x0030:  0800 7c55 0000 0101 080a 008a 6dd9 6328  ..|U........m.c(
        0x0040:  045e 0100 0000 01                        .^.....

client not send this packet.



 Comments   
Comment by markus makela [ 2018-04-30 ]

Managed to reproduce it with the following script.

#!/bin/bash                                                                                                                                                                                   
 
user=maxuser
password=maxpwd
host=127.0.0.1
port=4006
 
echo <<EOF > ./test.csv                                                                                                                                                                       
1   189427  08566691263-11954212384-49965520504-76648806909-97649256466-70808089694-75700327046-71097693010-15164106634-83838565200 66118511869-22681140063-09693510518-99105097351-492829648\
76                                                                                                                                                                                            
EOF                                                                                                                                                                                           
 
mysql -u $user -p$password -h $host -P $port -e "CREATE OR REPLACE TABLE test.localdata(id int, a int, b varchar(255), c varchar(100))"
mysql --delimiter "//" -u $user -p$password -h $host -P $port -e "LOAD DATA LOCAL INFILE './test.csv' INTO TABLE test.localdata; LOAD DATA LOCAL INFILE './test.csv' INTO TABLE test.localdat\
a"

Comment by markus makela [ 2018-04-30 ]

This is not very straightforward to fix in 2.2 as the LOAD DATA LOCAL INFILE processing is done when a query is received. The correct way to handle it would be to transition into a data processing state when the server responds with a LOCAL INFILE request packet and exit this state only when the client sends an empty packet.

Generated at Thu Feb 08 04:09:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.