List:Internals« Previous MessageNext Message »
From:Andrej van der Zee Date:March 24 2009 6:44am
Subject:Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL
server
View as plain text  
Hi,

Note that the mysql command LOAD DATA LOCAL INFILE does appears in the
mysql.log on the remote server. But, the rows in the file
'/dev/shm/mbrace_infile.txt' are never added to the table. So it looks
like the (contents of) the file never arrives at the server when I
issue the command from a background thread. Why?

Cheers,
Andrej


On Tue, Mar 24, 2009 at 2:18 PM, Andrej van der Zee
<andrejvanderzee@stripped> wrote:
> Hi,
>
> I am wondering why the LOAD DATA LOCAL INFILE command is not working
> from my custom background thread in MySQL. I read the documentation
> about the command carefully and set up the client and server to be
> able have this command supported. It works perfectly fine from the
> test program below. But if I use the same commands in my background
> thread in the MySQL server, then the call to mysql_query() hangs and
> eventually fails crashing the whole MySQL server. Issuing other
> queries in the background thread work perfectly fine, it seems to be
> just this LOAD DATA LOCAL INFILE command. Any ideas?
>
> Please help!
> Andrej
>
>
> #include <mysql.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char** argv)
> {
>  MYSQL *conn;
>
>  static const char * query = "LOAD DATA LOCAL INFILE
> '/dev/shm/mbrace_infile.txt' INTO TABLE request_mysql FIELDS
> TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\\"' LINES TERMINATED BY
> '\\n'";
>
>  for (int i=0; i<100; ++i)
>  {
>    conn = mysql_init(NULL);
>    if (!mysql_real_connect(conn, "mbrace3", "mbrace", "mbrace",
> "mbracelog", 3306, 0, CLIENT_LOCAL_FILES))
>    {
>      fprintf(stderr, "Failed to connect to mbracelog database: %s",
> mysql_error(conn));
>      return 1;
>    }
>
>    if (mysql_options(conn, MYSQL_OPT_LOCAL_INFILE, NULL))
>    {
>      fprintf(stderr, "Failed to set mysql option
> MYSQL_OPT_LOCAL_INFILE: %s", mysql_error(conn));
>      mysql_close(conn);
>      return 1;
>    }
>
>    if (mysql_query(conn, query))
>    {
>      fprintf(stderr, "Failed to execute query: %s: %s", query,
> mysql_error(conn));
>      mysql_close(conn);
>      return 1;
>    }
>
>    mysql_close(conn);
>  }
>
>  return 0;
> }
>



-- 
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-ku, Tokyo
166-0003 JAPAN
Mobile: +81-(0)80-65251092
Phone/Fax: +81-(0)3-3318-3155
Thread
LOAD DATA LOCAL INFILE in background thread brings down MySQL serverAndrej van der Zee24 Mar
  • Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL serverAndrej van der Zee24 Mar
  • Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL serverKristian Nielsen24 Mar
    • Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL serverAndrej van der Zee24 Mar
      • Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL serverAndrej van der Zee25 Mar
Re: LOAD DATA LOCAL INFILE in background thread brings down MySQL serverAndrej van der Zee25 Mar