Hope this makes sense

I'm seeing random hung reads() after a mysql insert that appears to be
related to a sig alarm race condition.  The basic workflow of this program
is

while (1) 
   recvfrom() /* few hundred packets a sec */
   parse packet
   insert into sql

However, once per second a sig alarm is generated which does house keeping
and what-not.   This will work for minutes or hours, but eventually the
read(3, ...) blocks , which is the mysql socket.  When this occurs you just
see the repeated sig alarms being catch, but immediately returning to that
read() which never returns.  Note there is still hundreds of udp packets
coming in but never able to be read because the never-returing read(3,) on
the mysql sock.

Normal syscalls resemble:

write(3, "\1\1\0\0\3INSERT INTO call_logging.de"..., 261) = 261
read(3, "\3\0\0\1", 4)                  = 4
read(3, "\0\1\0", 3)                    = 3
recvfrom(5, "...") = 398

Here is (hopefully enough) machine information:

*** Precompiled binaries from mysql.com.
*** Linux mmlog2 2.4.9-21smp #1 SMP Thu Jan 17 14:01:48 EST 2002 i686 unknown

*** My Program complied as such (tried both shared and static linked,)
*** Note, this program isn't making use of threads, and I've seen the same
*** results with -D_REENTRANT && -lpthread and without, as well as linking
*** the non _r libmysqlclient

gcc -o clconsumer -O -D_REENTRANT -g -lpthread -lm -lz -I/usr/include/mysql 
-I/usr/local/mysql/include clconsumer.o  /usr/local/mysql/lib/libmysqlclient_r.a

mysql  Ver 11.17 Distrib 3.23.49, for pc-linux-gnu (i686)

Connection id:          13
Current database:
Current user:           root@localhost
Current pager:          stdout
Using outfile:          ''
Server version:         3.23.49
Protocol version:       10
Connection:             Localhost via UNIX socket
Client characterset:    latin1
Server characterset:    latin1
UNIX socket:            /tmp/mysql.sock
Uptime:                 4 hours 55 min 3 sec

Threads: 4  Questions: 3261389  Slow queries: 0  Opens: 195  Flush tables: 1  Open 
tables: 7 Queries per second avg: 184.228
--------------

Here is the infinite syscalls when mysql isn't returning (expected?) data on
the socket?  

read(3, 0x814a6b0, 4)                   = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) ---
time(NULL)                              = 1014267832
rt_sigaction(SIGALRM, {SIG_IGN}, {0x4002fa10, [ALRM], SA_RESTART|0x4000000}, 8) = 0
alarm(1)                                = 0
rt_sigaction(SIGALRM, {0x4002fa10, [ALRM], SA_RESTART|0x4000000}, {SIG_IGN}, 8) = 0
sigreturn()                             = ? (mask now [])
read(3, 0x814a6b0, 4)                   = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) ---
time(NULL)                              = 1014267833
rt_sigaction(SIGALRM, {SIG_IGN}, {0x4002fa10, [ALRM], SA_RESTART|0x4000000}, 8) = 0
alarm(1)                                = 0
rt_sigaction(SIGALRM, {0x4002fa10, [ALRM], SA_RESTART|0x4000000}, {SIG_IGN}, 8) = 0
sigreturn()                             = ? (mask now [])
read(3, 0x814a6b0, 4)                   = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) ---

Cliff


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to