Hi,

A program I recently re-written part of to use a MySQL database is 
having a lot of problems.  The problems aren't very pronounced on my 
machine unless I run it under Rational Purify, but others report more 
problems.

When doing mysql_query(&mysql,myquerystring), I am getting back randomly 
the errors "Commands out of sync", or "Lost connection to MySQL server 
during query".  This happens within seconds from within Purify, so I 
don't think it's a time thing.  Note Purify isn't complaining about 
memory access or leak errors, it just appears to do something to my 
program to make these errors more apparent (speed?) (after about 10 
queries, but problems rarely at the same point)

My program is a multithreaded, cross platform, C++ server application. 
I'm using a singleton Database class for access to the DB.  On 
initialization, it connects to the DB.  I was hoping that I could re-use 
just one connection for the lifetime of my server.

To deal with the threads, all MySQL DB calls are protected within a 
common mutex.  At first, with getting "Commands out of sync", I assumed 
I'd done something wrong with my mutexes but after review it appears I 
haven't.

I also reviewed to make sure that I always called 
mysql_free_result(myresultset) after doing a query (SELECT, but not 
INSERT, UPDATE or DELETE), and within the mutex.  The help files for 
Commands out of sync suggests I'm perhaps doing things out of order, but 
after review I can't find anything that might cause it...I just have 20+ 
different methods making queries and possibily examining and reparsing 
the results before returning.

What strategy is recommended here?  I'm sufficiently exasperated that it 
seems my only alternative is to change each call to do a mysql_init and 
real_connect for each database query.  But this seems like a big 
performance hit to me.

Or I could just attempt to reconnect, and reissue the query each time 
this happens (which seems often), but that is ugly (code-wise) and may 
not solve it, I'd rather fix the problem or the symptom entirely.  But a 
possibility.

Help, recommendations, please!?  Maybe something I might be missing?

Using MySQL client and server libraries 3.23.33.  The other interesting 
note is that my application uses ACE libraries 
(http://www.cs.wustl.edu/~schmidt/ACE.html, very cool) to deal with 
platform specifics, threading, mutexes and other stuff...)  Namespace 
collisions with ACE is why I'm not using the C++ libraries.  I expect to 
make at least one query to the database every few minutes, so timeouts 
aren't really an issue.  The errors have 99% been tested on, and noticed 
on, Windows 2000 Pro SP1 on x86 arch.

TIA!
Charlie


---------------------------------------------------------------------
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